Creating a Django App
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.
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.
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.
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. #}
- Running startapp from outside the project's root directory, creating the app folder in the wrong place.
- Naming an app the same as a built-in Python module (like test or json), causing import conflicts.
- Forgetting to add the newly created app to INSTALLED_APPS, so Django never loads its models or templates.
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.
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: