# A Django Project and App — Django / FastAPI

Source: https://www.skillbyai.com/en/django-fastapi/i-django-layout

> startproject and startapp.

## Projects contain apps

A Django **project** holds settings, root URLs and the ASGI/WSGI entry points; **apps** are reusable components (catalog, orders, accounts), each with models, views, tests and migrations. Create them with `django-admin startproject` and `python manage.py startapp`, then add the app to `INSTALLED_APPS`. `manage.py` runs commands: `runserver`, `makemigrations`, `migrate`, `shell`, `test`, `createsuperuser`.

## Creating the demo project, run

I ran this with Django 6.1.1 and Python 3.12 in a demo project (shopsite with a catalog app) using SQLite. The generated files: a shopsite project package (settings, urls, asgi, wsgi) and a catalog app (models, views, admin, apps, tests), plus manage.py.

```bash
django-admin startproject shopsite .
python manage.py startapp catalog
find . -name "*.py" | sort
```

Output:

```
./catalog/admin.py
./catalog/apps.py
./catalog/__init__.py
./catalog/models.py
./catalog/tests.py
./catalog/views.py
./manage.py
./shopsite/asgi.py
./shopsite/__init__.py
./shopsite/settings.py
./shopsite/urls.py
./shopsite/wsgi.py
```

## Split settings per environment

Read secrets and environment-specific values from environment variables rather than editing settings.py per server.

**Quiz:** What must you do after startapp for Django to use the app?

- [x] Add it to INSTALLED_APPS
- [ ] Restart the computer
- [ ] Rename manage.py
- [ ] Nothing

*Answer:* Add it to INSTALLED_APPS. Apps are registered in settings.
