Skip to main content
Django Basics Tutorial
CHAPTER 05 Beginner

Django Apps and Project Structure

Updated: May 14, 2026
20 min read

# CHAPTER 5

Django Apps and Project Structure

1. Introduction

Django has a unique and strict organizational philosophy regarding Projects versus Apps. This is often the most confusing concept for beginners. In Django, a "Project" is the entire website, while an "App" is a small, modular component that handles a specific feature (like a blog, a forum, or a store). In this chapter, we will generate our first Django App, integrate it into our Project, and explore the internal folder structure that powers the MVT architecture.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Differentiate between a Django Project and a Django App.
  • Use manage.py startapp to create modular applications.
  • Register a new app within settings.py.
  • Understand the roles of views.py, models.py, and admin.py within an App.

3. Beginner-Friendly Explanation

Imagine your Django Project is a Shopping Mall. The Mall itself (core/settings.py) provides the electricity, the security guards, and the main entrance doors. However, a mall without stores is useless. A Django App is a specific Store inside the mall.
  • You build an App called shoes to sell shoes.
  • You build another App called foodcourt to sell food.
If the shoes App goes bankrupt, you can easily remove it from the mall without affecting the foodcourt. This modularity means you can take your shoes App and plug it into a completely different Mall (Project) in the future!

4. The Golden Rule: Project vs. App

  • A Project is the collection of configuration and apps for a particular website. (The Mall).
  • An App is a Web application that does something (e.g., a Weblog system, a database of public records or a simple poll app). (The Store).
  • *A project can contain multiple apps. An app can be in multiple projects.*

5. Step 1: Creating an App

Let's build a blog application. Ensure your virtual environment is active, and your terminal is in the same folder as manage.py.

Run the following command:

bash
1
python manage.py startapp blog

If you type ls (or dir), you will see a new folder named blog has been created next to your core folder.

6. Step 2: Exploring the App Structure

Open the new blog folder. You will see several files:
text
12345678
blog/
    __init__.py
    admin.py    (Registers your models with the Django Admin panel)
    apps.py     (Configuration for this specific app)
    models.py   (The Chef: Where you define database tables)
    tests.py    (Where you write automated tests to prevent bugs)
    views.py    (The Waiter: Where you write your business logic)
    migrations/ (A folder tracking changes to your database)

*Notice that Django automatically created views.py and models.py for us! This is the MVT architecture in action.*

7. Step 3: Registering the App

You built the store (blog), but the Mall (core) doesn't know it exists yet. We must give the store a lease.

Open core/settings.py. Scroll down until you find a list named INSTALLED_APPS. Add your new 'blog' app to the bottom of the list.

python
12345678910111213
# core/settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    # My custom apps
    'blog',
]

*(Always add a comma after your app name!)*

8. Backend Workflow: When to create a new App?

How do you know when to create a new App? Ask yourself: "If I delete this feature, will the rest of the site still work?" If you are building an E-Commerce site:
  • users (App for login/registration)
  • products (App for displaying items)
  • cart (App for checkout)
This keeps your codebase clean. If products/views.py gets to be 2,000 lines of code, it's much easier to manage than having a single file for the entire website.

9. Best Practices

  • App Naming Convention: App names should be plural, short, and descriptive nouns. users, posts, products, invoices. Do not use verbs (create_post) and do not use generic words (main, app1).

10. Common Mistakes

  • Forgetting to Register the App: The #1 mistake beginners make is spending two hours building database models in blog/models.py, running the database migration, and wondering why Django says "No changes detected." If the app is not listed in INSTALLED_APPS, Django will completely ignore the entire folder!

11. Exercises

  1. 1. Explain the "Shopping Mall" analogy. Why does Django encourage breaking a large website down into multiple smaller "Apps"?

12. Coding Challenges

  • Challenge: Using your terminal, create a second app named accounts intended to handle user logins and registrations in the future. Once created, successfully register the accounts app inside your settings.py file.

13. MCQs with Answers

Question 1

In Django terminology, what is the difference between a "Project" and an "App"?

Question 2

After running python manage.py startapp blog, what is the mandatory next step to ensure Django recognizes the new application?

14. Interview Questions

  • Q: Describe Django's modular App architecture. Provide a scenario where this modularity would allow a development team to reuse code across multiple entirely different company websites.
  • Q: Walk me through the files automatically generated by startapp. What is the specific purpose of models.py and admin.py?

15. FAQs

Q: Can I just build my whole website in one single App? A: Yes. If you are building a very simple, 3-page website, you can just create one app called pages and put everything in there. But for enterprise applications, modularity is essential.

16. Summary

In Chapter 5, we learned the crucial distinction between a Django Project (the overall container) and a Django App (a modular feature). We used manage.py startapp to generate our blog application, explored its MVT-ready internal file structure, and performed the critical step of registering the app within settings.py's INSTALLED_APPS list. Our project is now wired and ready to receive code.

17. Next Chapter Recommendation

Our App exists, but how do users navigate to it? Proceed to Chapter 6: Django URLs and Routing.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·