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

Changed explicit User relation to configurable setting #41

Merged
merged 2 commits into from Aug 19, 2015

Conversation

niktto
Copy link

@niktto niktto commented Jul 7, 2015

because hardcoding User in a ForeignKey stops people from specifing
alternative user models using settings.AUTH_USER_MODEL

This fix silences fields.E301 error raised by Django system check (https://docs.djangoproject.com/en/1.8/ref/checks/#related-fields) for users that, for example, use django-authtools or declare own user models based on django.contrib.auth.models.AbstractUser.

Thanks and best regards :),
Marek

because hardcoding User in a ForeignKey stops people from specifing
alternative user models using settings.AUTH_USER_MODEL
@funkaoshi
Copy link
Contributor

This breaks in Django 1.4. The easy fix here is to check if AUTH_USER_MODEL is an attribute of settings, and if it is not continue to import users.

@niktto
Copy link
Author

niktto commented Jul 7, 2015

Sorry for not noticing this @funkaoshi , I'll fix my PR and notify you when it's ready. Thanks! :)

@funkaoshi
Copy link
Contributor

@niktto No problem. Thanks for contributing. If you search around there are lots of examples of people doing what you are trying to do. We might need to change a migration as well. @emintham has been looking at this stuff as well as we look to upgrade our app to 1.7.

If we can't find user model specified in settings - we go back to
previous/old way of grabbing user model (straight import)
@niktto
Copy link
Author

niktto commented Jul 8, 2015

As for migrations, I can see that here https://github.com/sdelements/django-security/blob/master/security/migrations/0001_initial.py#L11 they are properly set to use User model specified in settings (only in new migrations, so there will be no problem with Django 1.4).

I use (my fork for now) django-security in Django 1.8 app with custom user model (django-authtools) and migrations work like a charm.

@funkaoshi
Copy link
Contributor

@niktto Sorry We haven't looked at this in ages! Will bug someone here to review and get this merged.

@shawngustaw
Copy link
Contributor

@funkaoshi +1

funkaoshi added a commit that referenced this pull request Aug 19, 2015
Changed explicit User relation to configurable setting
@funkaoshi funkaoshi merged commit e80b364 into sdelements:master Aug 19, 2015
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

Successfully merging this pull request may close these issues.

None yet

3 participants