Installation of Django on Virtual Environment
Install virtualenv
virtualenv environmentname
Note:- environmentname can be replace by any name you want for your environment.
Activate
environmentname\Scripts\activate
Note:- To deactivate virtual environment use following command.
deactivate
Install Django
pip install django
Verify your Django Installation
django-admin –version
Create Project in Django
django-admin startproject projectname
Note:- Replace projectname with the name of the project you want create.
Structure of The Project.
projectname/
ย ย ย ย ย ย manage.py
ย ย ย ย ย ย projectname/
ย ย ย ย ย ย ย ย ย ย ย ย _init_.py
ย ย ย ย ย ย ย ย ย ย ย ย settings.py
ย ย ย ย ย ย ย ย ย ย ย ย urls.py
ย ย ย ย ย ย ย ย ย ย ย ย asgi.py
ย ย ย ย ย ย ย ย ย ย ย ย wsgi.py
Create App in your Project
python manage.py startapp appname
Note:- Replace appname with the name of the App you want create.
Structure of The App.
appname/
ย ย ย ย ย ย _init_.py
ย ย ย ย ย ย admin.py
ย ย ย ย ย ย apps.py
ย ย ย ย ย ย migrations/
ย ย ย ย ย ย ย ย ย ย ย ย _init_.py
ย ย ย ย ย ย ย ย ย ย ย ย models.py
ย ย ย ย ย ย ย ย ย ย ย ย tests.py
ย ย ย ย ย ย _init_.py
ย ย ย ย ย ย admin.py
ย ย ย ย ย ย apps.py
ย ย ย ย ย ย migrations/
ย ย ย ย ย ย ย ย ย ย ย ย _init_.py
ย ย ย ย ย ย ย ย ย ย ย ย models.py
ย ย ย ย ย ย ย ย ย ย ย ย tests.py
ย ย ย ย ย ย ย ย ย ย ย ย views.py
Run Server
python manage.py runserver