I want to declare default_app_config
variable for my app, but I have an error:
django.core.exceptions.ImproperlyConfigured: Cannot import 'accounts'. Check that 'apps.accounts.apps.AccountsConfig.name' is correct.
All my apps is located in directory apps:
project_name/
apps/
app1/
app2/
....
accounts/
I am using my apps like this:
INSTALLED_APPS = [
# Local Apps
'apps.category',
'apps.products',
'apps.cart',
'apps.orders',
'apps.accounts',
'apps.attributes',
'apps.pages',
'apps.compare',
'apps.filters',
'apps.brands'
]
And now when I want to set default_app_config
for my app, I get the error above.
__init__.py
in app folder:
default_app_config = 'apps.accounts.apps.AccountsConfig'
apps.py
in app folder:
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
verbose_name = 'Пользователи'
Why I get the error?
The AppConfig class used to configure the application has a path class attribute, which is the absolute directory path Django will use as the single base path for the application.
You can get application name from model: Book. _meta. app_label .
AppConfig name is full python path to the application. So try...
name = 'apps.accounts'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With