006-Django - Create App

Objectives: Django - Create App

Django - Create App

Django - Create App

What is an App?

In Django, an app is a small web application inside your project. Each app has a specific purpose — for example:

  • A home app for your main page.
  • A contact app for your contact form.
  • A members app for managing users in your system.

Real-life Example:

Think of a Django project as a company, and each app as a department. One department handles HR (members), another handles Finance (payments), and another handles Marketing (blog). All departments (apps) together form the company (project).

Advice:

Don’t put everything in one app. Split your project into multiple apps — this makes your code easier to manage and reuse.

1. Create the App

In this tutorial, we’ll create an app called members.

First, stop the server if it’s running:

  • Press [CTRL] + [C] or [CTRL] + [BREAK] in your terminal.

Now, run this command in your project folder (for example, my_tennis_club):

python manage.py startapp members

2. Folder Structure

Django will create a folder named members with this structure:

my_tennis_club/
    manage.py
    my_tennis_club/
    members/
        migrations/
            __init__.py
        __init__.py
        admin.py
        apps.py
        models.py
        tests.py
        views.py
  

Real-life Example:

Each file has a specific role, like employees in a team:

  • views.py → The employee who answers customer requests (decides what to show).
  • models.py → The employee managing the database (records of members).
  • admin.py → The manager who controls things through Django’s admin panel.
  • tests.py → The inspector who checks if everything works properly.

3. First Step – Hello World

Let’s keep it simple. Open views.py inside the members folder. Add this code:

from django.http import HttpResponse def index(request): return HttpResponse("Hello World!")

This is our first Django view — it returns a simple "Hello World!" message.

Advice:

Start with small experiments like "Hello World!" before diving into databases or templates. This helps you clearly see how Django handles requests and responses.

Next Step

In the next chapter, you’ll learn how to connect this view to a URL, so you can open http://127.0.0.1:8000/members/ in your browser and see "Hello World!".

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::