006-Django - Create Project

Objectives: Django - Create Project

Django - Create Project

Create Your First Django Project

Step 1: Choose a Project Name

Once you have a suitable name for your Django project, for example: my_tennis_club, navigate to the folder where you want to store the code (usually inside a virtual environment).

Advice:

Choose a project name without spaces or special characters. Use _ or lowercase letters. Example: myshop, student_portal.

Step 2: Run the Startproject Command

django-admin startproject my_tennis_club
  

This will create a folder my_tennis_club with the following structure:

my_tennis_club/
    manage.py
    my_tennis_club/
        __init__.py
        asgi.py
        settings.py
        urls.py
        wsgi.py
  

Real-life Example:

Think of manage.py as the "remote control" to manage your project (start server, run migrations, create apps).

  • settings.py – like the "control center" of your project (database setup, installed apps).
  • urls.py – like the "GPS" that decides which page (view) you go to.
  • wsgi.py & asgi.py – help Django talk to web servers (advanced, you’ll learn later).

Advice:

Don’t worry if you don’t understand all these files yet. At the beginning, focus on settings.py and urls.py.

Step 3: Run the Django Project

Navigate inside the my_tennis_club folder and run:

python manage.py runserver
  

If everything is correct, you’ll see output like:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s).
Run 'python manage.py migrate' to apply them.

Django version 5.1.7, using settings 'my_tennis_club.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
  

Now, open a browser and visit:

http://127.0.0.1:8000/
  

Real-life Example:

This is like turning on the lights in your new house. You don’t have furniture (apps) yet, but the structure is ready, and the power is working.

Advice:

If you see an error like "port already in use", try running python manage.py runserver 8080 (or another port number).

What’s Next?

Congratulations 🎉 You now have your first Django project running!

The next step is to create an app inside the project.

Why Apps?

You cannot have a real Django webpage without an app. Think of:

  • Project = the entire "company".
  • App = a "department" inside the company (e.g., blog, shop, accounts).

Advice:

Start with a simple app like blog or tasks (To-Do list). This makes learning practical and fun.

Reference Book: N/A

Author name: SIR H.A.Mwala Work email: biasharaboraofficials@gmail.com
#MWALA_LEARN Powered by MwalaJS #https://mwalajs.biasharabora.com
#https://educenter.biasharabora.com

:: 1::