Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular import with get_user_model #90

Open
b-jam opened this issue Nov 6, 2014 · 2 comments
Open

Circular import with get_user_model #90

b-jam opened this issue Nov 6, 2014 · 2 comments

Comments

@b-jam
Copy link

b-jam commented Nov 6, 2014

Its fine to import, but if you import a model from this app from within your own models.py file, it will cause a circular error due to the get_user_model() running from within the code. see
http://stackoverflow.com/questions/17469682/django-1-5-accessing-custom-user-model-fields-in-models-py
for a very relevant case and how they solved.

@b-jam
Copy link
Author

b-jam commented Nov 6, 2014

The Django documentation has the answer: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.get_user_model

The most relevant section: Generally speaking, you should reference the User model with the AUTH_USER_MODEL setting in code that is executed at import time. get_user_model() only works once Django has imported all models.

@b-jam
Copy link
Author

b-jam commented Nov 11, 2014

The problem is models.py::formlog::created_by field. This field is not inside any method. So if you import this from your own models it will crash. a fix would be to put this inside a method or change it to use the AUTH_USER_MODEL setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant