2.3. Apps

2.3.1. Reusability

2.3.2. Location

2.3.3. Create

$ cd addressbook
$ django-admin startapp myapp
# settings.py
INSTALLED_APPS += ['myproject.myapp.apps.ContactConfig']

2.3.4. Structure

myproject/
    manage.py
    myproject/
        __init__.py
        asgi.py
        settings.py
        urls.py
        wsgi.py
    myapp/
        __init__.py
        admin.py
        migrations/
            __init__.py
            0001_initial.py
        models.py
        static/
            myapp/
                img/
                    image.png
                css/
                    style.css
                js/
                    script.js
        templates/
            myapp/
                detail.html
                index.html
                results.html
        tests.py
        urls.py
        views.py

2.3.5. Configuration

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class ContactConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'myapp'
    verbose_name = _('MyApp')