- November 25, 2020
- saptrxuy_learnit
- 0 Comments
- 1475 Views
- 0 Likes
- Django, Python
How to install and create Django-project
1. Check python version
2. Check pip version
3. Install virtualenvwrapper
4. Create a virtual environment for your project
5. Install Django in activate environment
6. Check Django version
7. Activate your virtual environment
8. Create Django project
9. Run the Django Projects
10. Make migration if you have added something
11. Migrate
12.Create super user for backend control
13.Start the server snd check admin pannel
14.Stop the server and deactivate the virtual env
15.Open command prompt and activate your virtual env
16.Create Django project
17.Create app
18.Make your app entry in installed Apps in setting.py
19.Create view for your app
20.Create url mapping for views in Django projects
21.Run tne server
22.Check url
1.Check python versionâ–²
Python –version
2.Check pip versionâ–²
Pip –version
3.Install virtualenvwrapperâ–²
3.1.Open another command prompt ->Run as Administrator ▲
pip install virtualenvwrapper-win
4. Create a virtual environment for your project▲
4.1. Go to your project folder in command prompt where you want to create your project▲
Changing directory to my Django project folder
- Create virtual environment
mkvirtualenv mydjango_venue
5.Install Django in activate environmentâ–²
pip install django
6.Check Django versionâ–²
6.1.django-admin –version▲
7.Activate your virtual environmentâ–²
7.1.Open command promptâ–²
workon mydjago_ment
8.Create Django projectâ–²
django-admin startproject djangodemo
9.Run the Django Projectsâ–²
9.1.9.1.Go to your newly created django project ▲
cd djangodemo
9.2. ▲
9.3. 9.2.Start the server▲
python manage.py runserver
9.4.9.3.Check below url in browserâ–²
you will get the below output
10.Make migration if you have added somethingâ–²
10.1. 10.1.Makemigrations is responsible for creating new migrations based on the changes yu have made to your models.▲
Stop server by pressing ctrl + c, then type below command
python manage.py makemigrations
11.Migrateâ–²
11.1.11.1.Migrate is responsible for applying and unapplying migrationsâ–²
python manage.py migrate
12.Create super user for backend controlâ–²
python manage.py createsuperuser
13.Start the server snd check admin pannelâ–²
python manage.py runserver
http://127.0.0.1:8000/admin/login/?next=/admin/
14.Stop the server and deactivate the virtual envâ–²
Ctrl + c
Deactivate
15.Open command prompt and activate your virtual envâ–²
Go to your project folder and type below command in cmd
workon mydjango_ment
16.Create Django projectâ–²
I have already created my Django project. So not going to create new one. If you have not created then you can follow my previous documentation. Link is given below:
http://tm.xcelvations.com/static-pages/python/django/create-django-website-in-windows.pdf
17.17. Create appâ–²
17.1. 17.1.Go to inside your Django project in command prompt▲
cd djangodemo
17.2.17.2.Create appâ–²
python manage.py startapp myapp
We can see myapp created inside Django project folder
Files and directories we can see.
18.18.Make your app entry in installed Apps in setting.pyâ–²
Open setting.py file inside your Django project(D:\djangofirst\djangofirst\djangofirst\setting.py)
19.19. Create view for your appâ–²
19.1.19.1.Open views.py, it will be inside D:\Django-projects\djangofirstmyapp\views.pyâ–²
19.2. 19.2.Create one method in views.py▲
from django.shortcuts import render
from django.http import HttpResponse
def home(request):
return HttpResponse(“Hello World”)