Example, for a project of such structure:
{{{
.
└── DjangoProject/
└── Apps/
├── bestapp/
│ ├── migrations
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
└── ...
}}}
When adding this line to DjangoProject/settings.py:
{{{
INSTALLED_APPS = [
...
'Apps.bestapp.apps.BestappConfig'
]
}}}
The following exception is thrown when running {{{python manage.py
makemigrations}}}:
{{{
django.core.exceptions.ImproperlyConfigured: Cannot import 'bestapp'.
Check that 'Apps.bestapp.apps.BestappConfig.name' is correct.
}}}
The current workaround is to go into the Apps/bestapp/apps.py file and
make the following change:
Auto-generated version:
{{{
class BestappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'bestapp'
}}}
Manually-Updated version:
{{{
class BestappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Apps.bestapp'
}}}
Note the change being adding the parent directory here: {{{name =
'Apps.bestapp' }}}
IIRC, there was a syntax change for app installation somewhere in 3.x. Not
sure if this is a product of that change or something else.
--
Ticket URL: <https://code.djangoproject.com/ticket/33378>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
* component: Core (Other) => Core (Management commands)
Comment:
Thanks for the report, however it works exactly the same in Django 3.2,
3.1, etc. I don't see any change in this behavior. `AppConfig.name` must
be a full Python path to the application, as
[https://docs.djangoproject.com/en/4.0/ref/applications/#django.apps.AppConfig.name
documented], so in your case `Apps.bestapp` is required and expected. We
tried to improve generated `apps.py` files in #30618 but it was clunky.
Duplicate of #30618.
--
Ticket URL: <https://code.djangoproject.com/ticket/33378#comment:1>
Comment (by Zack West):
Thanks and sorry for the duplicate post. It wasn't so much the requirement
of the full path I noted as much as it was Django *generating* a non-
fullpath when running the `python manage.py startapp` command or, more
particularly, if one is in a subdirectory (e.g. apps/) and runs the
command `django-admin startapp myapp` the `name` field in
`apps/myapp/apps.py` config class gets auto-populated with just `myapp`
rather than the required `apps.myapp` which will throw a
`django.core.exceptions.ImproperlyConfigured` exception unless a user
manually updates the `name` field.
I understand if that was passed over but I wanted to ensure I was drawing
attention to the proper aspect of the issue.
Replying to [comment:1 Mariusz Felisiak]:
> Thanks for the report, however it works exactly the same in Django 3.2,
3.1, etc. I don't see any change in this behavior. `AppConfig.name` must
be a full Python path to the application, as
[https://docs.djangoproject.com/en/4.0/ref/applications/#django.apps.AppConfig.name
documented], so in your case `Apps.bestapp` is required and expected. We
tried to improve generated `apps.py` files in #30618 but it was clunky.
>
> Duplicate of #30618.
--
Ticket URL: <https://code.djangoproject.com/ticket/33378#comment:2>