6. Apps

6.1. Reusability

6.2. Location

Code Listing 6.40. Django Apps Location

6.3. Create

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

6.4. Structure

Code Listing 6.41. Django Apps Structure
mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    polls/
        __init__.py
        admin.py
        migrations/
            __init__.py
            0001_initial.py
        models.py
        static/
            polls/
                images/
                    background.gif
                style.css
        templates/
            polls/
                detail.html
                index.html
                results.html
        tests.py
        urls.py
        views.py
    templates/
        admin/
            base_site.html

6.5. Configuration

Code Listing 6.42. Django Apps Configuration
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class ContactConfig(AppConfig):
    name = 'contact'
    verbose_name = _('Contact')