- November 25, 2020
- saptrxuy_learnit
- 0 Comments
- 1557 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”)
20.20. Create url mapping for views in Django projects▲
20.1.20.1.Open urls.py files(D:django-projects\djangofirst\djangofirst\urls.py)▲
20.2. 20.2.Create url mapping in urls.py▲
You have to import method from myapp
from myapp.views import home
urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘home/’, home),
]
Save and close the file.
21.21. Run tne server▲
python manage.py runserver
Leave a Comment