3.3. Setup Start App

  • Re-usability

  • Location

3.3.1. Create App

Run in system terminal:

$ cd myproject
$ django-admin startapp shop

Structure:

myproject
├── db.sqlite3
├── manage.py
├── shop
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
└── myproject
    ├── __init__.py
    ├── asgi.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

3.3.2. Setup

Append to myproject/settings.py:

>>> INSTALLED_APPS += ['shop.apps.ShopConfig']

3.3.3. Configure

File myproject/shop/apps.py:

>>> from django.apps import AppConfig
>>> from django.utils.translation import gettext_lazy as _
>>>
>>>
>>> class ShopConfig(AppConfig):
...     default_auto_field = 'django.db.models.BigAutoField'
...     name = 'shop'
...     verbose_name = _('Shop')
...     verbose_name_plural = _('Shops')

3.3.4. Assignments

Code 3.91. Solution
"""
* Assignment: Django Conf RunConfiguration
* Complexity: medium
* Lines of code: 0 lines
* Time: 8 min

English:
    1. Create app `shop`
    2. Modify file `myproject/shop/apps.py`:
        a. add `from django.utils.translation import gettext_lazy as _`
        b. add `verbose_name = _('Shop')` in class `ShopConfig`
    2. Add app to `INSTALLED_APPS` in `myproject/settings.py`
    3. Run doctests - all must succeed

Polish:
    1. Stwórz aplikację `shop`
    2. Zmodyfikuj plik `myproject/shop/apps.py`:
        a. dodaj `from django.utils.translation import gettext_lazy as _`
        b. dodaj `verbose_name = _('Shop')` w klasie `ShopConfig`
    2. Dodaj aplikację do `INSTALLED_APPS` w `myproject/settings.py`
    3. Uruchom doctesty - wszystkie muszą się powieść
"""