Creating a Django project
This episode covers :-
1.) How to create a new Django project.
2.) How to use the built-in development server.
- Setup :-
Terminal
cd projects
mkdir 08-Django-Project
cd 08-Django-Project
source ../venv/bin/activate
You don’t have to activate the virtual environment if it’s already activated.
- Creating a new Project :-
Install Django and use the startproject command to create a new Django project:
Terminal
pip install django
django-admin startproject mysite .
You should now have this kind of folder structure:
Project folder structure
projects
├── 08-Django-Project
│ ├── manage.py
│ └── mysite
└── venv
├── bin
├── include
├── lib
├── pip-selfcheck.json
└── pyvenv.cfg
08-Django-Project folder is a container for the whole project. The mysite folder inside it is the project Python package that connects your project with Django.
- Running the development server :-
Use runserver to run the server:
Terminal
python manage.py runserver
Visit http://127.0.0.1:8000/ and you should see the welcome screen:
- In Details :-
- django-admin is a command-line tool for administrative tasks.
- startproject command creates a Django project skeleton.
- It’s more convenient to use manage.py instead of django-admin for administrative tasks after the project has been created.
- SQLite is the default database option but you shouldn’t use it in a production environment.


No comments:
Post a Comment
If you have any doubts. Please let me know.