This post is about creating a Django project manually. If you are one among who hates using the command line, read my post about Creating a Django project with Visual Studio.
Creating the project
A Django project is a collection of applications organized in different folders. To create a Django project Run the following command after navigating to the directory where you want your Django projects to be created.
django-admin startproject DjangoProject
This will create a folder named DjangoProject with a structure similar to the one shown below.
C:. │ manage.py │ └───DjangoProject settings.py urls.py wsgi.py __init__.py
- manage.py – A command line utility with which you can interact with the project.
- __init__.py – This file that tells Python that this directory is a Python package.
- settings.py – Holds the project settings.
- urls.py – Contains the links used in the project.
- wsgi.py – An entry-point for WSGI-compatible web servers to serve your project.
Running the project
Navigate to the root directory of the project and run the following command.
python manage.py runserver
This will give the following output:
Performing system checks… System check identified no issues (0 silenced). You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. March 15, 2019 - 13:48:23 Django version 2.1.7, using settings 'DjangoProject.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.
Now, we’ve started the built-in Django web server. Visit http://127.0.0.1:8000/ in your web browser. You’ll see a welcome page.
Note: Django development server is a lightweight Web server written in Python. It should not be used in production environment.