ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Django Tutorial• 7 min read

Project vs App Structure & settings.py

Organizing modular components and configuring production settings

In Django, a "project" is an entire web application configuration and collection of apps, while an "app" is a self-contained, reusable web module that does something specific (e.g., a blog, store, or poll).

Creating and Registering Modular Apps

python manage.py startapp <name>: Scaffolds a new app folder with models.py, views.py, admin.py, and apps.py.

INSTALLED_APPS: Must include your new app name in settings.py so Django recognizes its models, migrations, and templates.

settings.py essentials: SECRET_KEY, DEBUG (always False in production), ALLOWED_HOSTS, and DATABASES.

Configuring settings.py and App Registration
# settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    # Custom project apps
    'courses.apps.CoursesConfig',
    'analytics.apps.AnalyticsConfig',
]

# Database configuration (PostgreSQL)
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'codexia_db',
        'USER': 'postgres',
        'PASSWORD': 'SecurePassword123',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
Apps are isolated modules that can be ported between different Django projects.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which list in settings.py must contain your newly created app for Django to track its models and migrations?