5.1. Data App

5.1.1. Assignments

# FIXME: Write tests

# %% About
# - Name: Django Models CaseStudy
# - Difficulty: easy
# - Lines: 2
# - Minutes: 2

# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% English
# 0. Use `myproject`
# 1. Create app `shop`
# 2. Add app to `INSTALLED_APPS` in `myproject/settings.py`
# 3. Run doctests - all must succeed

# %% Polish
# 0. Użyj `myproject`
# 1. Stwórz aplikację `shop`
# 2. Dodaj aplikację do `INSTALLED_APPS` w `myproject/settings.py`
# 3. Uruchom doctesty - wszystkie muszą się powieść

# %% Doctests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 10), \
'Python 3.10+ required'
"""

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -f -v myfile.py`

# %% Imports

# %% Types

# %% Data

# %% Result

# FIXME: Write tests

# %% About
# - Name: Django Models CaseStudy
# - Difficulty: easy
# - Lines: 2
# - Minutes: 2

# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% English
# 0. Use `myproject.shop`
# 1. Modify file `myproject/shop/apps.py`:
#    - add `from django.utils.translation import gettext_lazy as _`
#    - add `verbose_name = _('Shop')` in class `ShopConfig`
# 2. Run doctests - all must succeed

# %% Polish
# 0. Użyj `myproject.demo`
# 1. Zmodyfikuj plik `myproject/demo/apps.py`:
#    - dodaj `from django.utils.translation import gettext_lazy as _`
#    - dodaj `verbose_name = _('Shop')` w klasie `ShopConfig`
# 2. Uruchom doctesty - wszystkie muszą się powieść

# %% Doctests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 10), \
'Python 3.10+ required'
"""

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -f -v myfile.py`

# %% Imports

# %% Types

# %% Data

# %% Result

# TODO: Create Tests
# doctest: +SKIP_FILE
# %% About
# - Name: Django Models CaseStudy
# - Difficulty: easy
# - Lines: 4
# - Minutes: 5

# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% English
# 0. Use `myproject.shop`
# 1. Remove file `myproject/shop/models.py`
# 2. Make directory `myproject/shop/models`
# 3. Make file `myproject/shop/models/__init__.py`

# %% Polish
# 0. Użyj `myproject.shop`
# 1. Skasuj plik `myproject/shop/models.py`
# 2. Stwórz katalog `myproject/shop/models`
# 3. Stwórz plik `myproject/shop/models/__init__.py`

# %% Doctests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 10), \
'Python 3.10+ required'
"""

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -f -v myfile.py`

# %% Imports

# %% Types

# %% Data

# %% Result