← Back to Django Course | Chapter 2: Apps, URLs & Views | Lesson 2 of 10

Creating a Django App

The startapp command asks Django to build an empty toy box with all the right folders and files already labeled for you.

Running startapp

From the directory containing manage.py, run python manage.py startapp <app_name>. Django generates a new folder with the standard app layout: models.py, views.py, admin.py, apps.py, and a migrations package.

Note: Use short, lowercase, singular app names like blog or accounts — they become part of Python import paths.

Example: Running startapp

From the directory containing manage.py, run python manage.py startapp <app_name>. Django generates a new folder with the standard app layout: models.py, views.py, admin.py, apps.py, and a migrations package.

bash
python manage.py startapp blog

⚠️ Run this command in your terminal.

Inspecting the Generated Files

After startapp runs, list the new folder to see exactly what Django created. Each file already has minimal boilerplate so you know where to add your own code.

Example: Inspecting the Generated Files

After startapp runs, list the new folder to see exactly what Django created. Each file already has minimal boilerplate so you know where to add your own code.

bash
ls blog/
# admin.py  apps.py  __init__.py  migrations/  models.py  tests.py  views.py

⚠️ Run this command in your terminal.

The apps.py Config File

startapp also creates apps.py with an AppConfig subclass. Django uses this class internally to identify the app, and its name attribute must match the app's Python package path.

Example: The apps.py Config File

startapp also creates apps.py with an AppConfig subclass. Django uses this class internally to identify the app, and its name attribute must match the app's Python package path.

markup
from django.apps import AppConfig

class BlogConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'blog'
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}
Common Mistakes
  1. Running startapp from outside the project's root directory, creating the app folder in the wrong place.
  2. Naming an app the same as a built-in Python module (like test or json), causing import conflicts.
  3. Forgetting to add the newly created app to INSTALLED_APPS, so Django never loads its models or templates.
Chapter Summary
  • python manage.py startapp <name> scaffolds a new app folder with models.py, views.py, and more.
  • Run startapp from the same directory as manage.py so the app lands at the project root.
  • Creating the app is only step one — it still needs to be registered before Django recognizes it.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.