Circular Import in settings.py #102

Closed
garromark opened this Issue Jul 26, 2012 · 3 comments

2 participants

@garromark

The get_model() method in settings.py is causing a circular import and is raising an exception

AttributeError: 'module' object has no attribute 'settings'

Basically, get_model() is requiring models.py to load, which has the import statement:

from actstream import ... settings as actstream_settings

So you have actstream.settings importing actstream.models trying to import actstream.settings. I'm not really sure you're going to get around this while keeping get_model() in settings.py. I'm really interested in what you can do as a fix for this.

@justquick
Owner

get_model should not be requiring actstream.models to load. what settings are you using?

@garromark

Taking a look at AppCache._populate() in django.db.models.loading.py from which get_model() is loaded in Django 1.4, I notice that the app_names are loaded from settings.INSTALLED_APPS. I have "actstream" in my INSTALLED_APPS, so it's loading models.py from actstream.

@justquick
Owner

fixed in master by adding settings.get_models which returns the model lookup when called instead of imported. expect this change in v0.4.4

one caveat to your suggestions is that the reverse lookup can contain any actionable model not just users. to get just users, call something like following(request.user, User)

@justquick justquick closed this Jul 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment