Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ from app.base_config import AppConfig


class {{ camel_case_app_name }}Config(AppConfig):
default = True
name = "{{ app_name }}"
8 changes: 6 additions & 2 deletions {{ cookiecutter.name }}/src/app/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from django.apps import AppConfig as DjangoAppConfig
from django.utils.translation import gettext_lazy as _

from app.base_config import AppConfig as BaseAppConfig

class AppConfig(DjangoAppConfig):

class AppConfig(BaseAppConfig):
default = True
name = "app"
verbose_name = _("Application")
12 changes: 8 additions & 4 deletions {{ cookiecutter.name }}/src/app/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@


class AppConfig(BaseAppConfig):
"""Default App configuration template. Import app.signals.handers.
"""Default App configuration template. Imports app.signals.handlers.

We do not recomend you to use django signals at all.
We do not recommend you to use django signals at all.
Check out https://lincolnloop.com/blog/django-anti-patterns-signals/ if
you know nothing about that.

Allthough, if you wish to use signals, place handlers to the `signals/handlers.py`:
your code be automatically imported and used.
Although, if you wish to use signals, place handlers to the `signals/handlers.py`:
your code will be automatically imported and used.
"""

# Django's `apps.py` scan sees two configs — yours and this one, pulled in by your import.
# `False` here, `True` in your subclass: otherwise Django silently takes a plain AppConfig.
default = False

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это default нужен чтоб брался правильно сконфигурированный класс из my_app/app.py

Иначе при регистрации приложения в installed_app попадал класс AppConfig — в своё время несколько часов пришлось дебажить почему переводы приложений в админку не доходят.


def ready(self) -> None:
"""Import a module with handlers if it exists to avoid boilerplate code."""
with contextlib.suppress(ModuleNotFoundError):
Expand Down
2 changes: 0 additions & 2 deletions {{ cookiecutter.name }}/src/app/conf/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
LOCALE_PATHS = [
SRC_DIR / ".locale",
]

USE_i18N = True

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это:

  • не нужно, т.к. теперь True всегда по дефолту
  • никогда не работало, т.к. ключ с ошибкой (должен быть USE_I18N iI)

9 changes: 9 additions & 0 deletions {{ cookiecutter.name }}/src/users/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.utils.translation import gettext_lazy as _

from app.base_config import AppConfig as BaseAppConfig


class AppConfig(BaseAppConfig):
default = True
name = "users"
verbose_name = _("Users")
Loading