In this section, we learn how to create a new Django project using the django-admin startproject command. This command initializes the basic project structure required to start building a Django application.
django-admin utility provides administrative commands.The startproject command creates a project directory with essential configuration files such as settings, URL routing, and WSGI configuration.
// Create a new Django project using django-admin
django-admin startproject myproject
After running the command, Django generates the following directory structure:
// Default Django project structure
myproject/
manage.py
myproject/
__init__.py
settings.py
urls.py
wsgi.py
Navigate to the project directory and start the development server:
// Navigate to project folder
cd myproject
// Start Django development server
python manage.py runserver
// Default server startup output
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Visiting http://127.0.0.1:8000/ in your browser displays the Django welcome page, confirming that the project setup is successful.
The Django development server automatically reloads when you change code files. Try stopping and restarting the server to observe how changes are reflected instantly.
settings.py carefully before production deployment.urls.py and explore URL routing.