question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autodiscovery fails when using AppConfig install

See original GitHub issue

i’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:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zyprocommented, Nov 16, 2018

The install string in the docs is ‘moderation.apps.SimpleModerationConfig’ insead of ModerationConfig!! That’s the important difference.

1reaction
tlawren3commented, Nov 18, 2019

I’m experiencing this issue in a similar manner.

relevant section of installed_apps:

    'moderation',
    'users.apps.UsersConfig',
    'core',

when I insert moderation into my installed_apps and attempt to migrate, I get this error:

 File "/Users/tlawrence/.conda/envs/hiccup/lib/python3.7/site-packages/moderation/apps.py", line 13, in ready
    auto_discover()
  File "/Users/tlawrence/.conda/envs/hiccup/lib/python3.7/site-packages/moderation/helpers.py", line 48, in auto_discover
    import_moderator(app)
  File "/Users/tlawrence/.conda/envs/hiccup/lib/python3.7/site-packages/moderation/helpers.py", line 27, in import_moderator
    app_path = import_module(app).__path__
  File "/Users/tlawrence/.conda/envs/hiccup/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'users.apps.UsersConfig'; 'users.apps' is not a package

I confirmed that it works if I remove moderation from my installed apps. Please advise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Error in Autodiscover application
When I run localhost\autodiscover\autodiscover.xml I get an autodiscover error as below [I have removed the PublicKeyToken and replaced with ...
Read more >
Why isn't admin.autodiscover() called automatically in ...
The autodiscover() was moved to the admin app's default app config. That means that autodiscover now runs when the admin app is loaded,...
Read more >
Bypassing the Microsoft Exchange AutoDiscovery Feature ...
NOTE: When upgrading to a newer version of GFI Archiver, installation files mentioned in this procedure will be overwritten with default ...
Read more >
Autodiscover | Filebeat Reference [8.5]
This configuration launches a docker logs input for all containers running an image with redis in the name. labels.dedot defaults to be true...
Read more >
Deployment Error When Configuring API Autodiscovery
This issue occurs if you did not add the apiId property in the config.properties file, and failed to modify the value for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found