autodiscovery fails when using AppConfig install
See original GitHub issuei’m new to django-moderation and somewhat new to django as well, so I apologize if I’m overlooking something basic. I’ve been unable to add 'moderation.apps.ModerationConfig'
to INSTALLED_APPS
– even with a fresh django startproject
(django 1.11.9) – due to what seems to be an incompatibility with the way helpers.auto_discover
pulls directly from settings.INSTALLED_APPS
… I get the error:
ModuleNotFoundError: No module named 'moderation.apps.ModerationConfig'; 'moderation.apps' is not a package
(and I get the same error with all of my custom apps that are installed using appConfig paths instead of package names). This makes sense of course, since helpers.import_moderator()
can’t use import_module()
to directly import the AppConfig class itself. The only way I can get it to work is by changing the auto_discover function to use get_app_configs()
:
def auto_discover():
from django.apps import apps
for app in [app.name for app in apps.get_app_configs() if app != 'moderation']:
import_moderator(app)
However, using 'moderation.apps.ModerationConfig'
as the install string is described in the docs, so I feel I must be in error somehow?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
The install string in the docs is ‘moderation.apps.SimpleModerationConfig’ insead of ModerationConfig!! That’s the important difference.
I’m experiencing this issue in a similar manner.
relevant section of installed_apps:
when I insert moderation into my installed_apps and attempt to migrate, I get this error:
I confirmed that it works if I remove moderation from my installed apps. Please advise.