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

Registration cycle with custom and historized User model and simple-history 2.5.0 #459

Closed
pm13 opened this issue Oct 19, 2018 · 3 comments · Fixed by #460
Closed

Registration cycle with custom and historized User model and simple-history 2.5.0 #459

pm13 opened this issue Oct 19, 2018 · 3 comments · Fixed by #460

Comments

@pm13
Copy link

pm13 commented Oct 19, 2018

Describe the bug
I have custom user model in module which imports simple_history.models (I think it is common to register historical records in models.py with custom user model.) It worked with simple-history 2.4.0.

But there is new call of get_user_model on class level (3726327). It raises exception:

File ".../models.py", line ..., in
import simple_history.models
File ".../simple_history/models.py", line 29, in
User = get_user_model()
File ".../django/contrib/auth/init.py", line 170, in get_user_model
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model '....User' that has not been installed

Class level User variable is used only once - so it is quite simple to call get_user_model in get_extra_fields method (one line down :)) - it solves problem.

To Reproduce

  1. Define custom user model and import simple_history.models in models.py (for historization of users).
  2. Set AUTH_USER_MODEL to this model.

Environment:

  • Django Simple History Version: 2.5.0
  • Django Version: 2.1.2
@rossmechanic
Copy link
Collaborator

Thanks for catching the @pm13. I'll try to merge a bugfix ASAP. Can you describe a little more clearly what fixed the issue? I'm looking at #435 now and also looking at https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#referencing-the-user-model. @ThePumpingLemma think we should just revert that commit based on django docs?

@rossmechanic
Copy link
Collaborator

Just put up a PR for the fix. Going to have @ThePumpingLemma review and then merge. Should have a release with the fix out by EOD

@pm13
Copy link
Author

pm13 commented Oct 19, 2018

I modify the patch - it was my solution of the problem. It is not full revert but only move of get_user_model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment