Closed tonjo closed 10 years ago
In test_settings.py
we had to put the app where AUTH_USER_MODEL
is defined.
I'm thinking to enhance the customization.
I saw the django authentication backend looks for USERNAME_FIELD
, so we can define our own.
AbstractBaseUser
is there exactly for that purpose, since it defines only password
, is_active
and last_login
.
Maybe we could derive from it?
Maybe we don't even need a custom backend, just a custom user, not sure about that.
Did you have a look at this, @mhluongo? It fixes the wrong type when authenticating. Reading the doc it seems the issue is only with Django 1.4, but it's still present in 1.5.
@tonjo This is a backwards-incompatible change- maybe there's a less heavy-handed approach? Eg by testing the import, like
try:
from django.contrib.auth import get_user_model
UserModel = get_user_model()
except ImportError:
from .models import User as UserModel
I'd rather keep support for Django 1.4 and support 1.5, rather than just 1.5.
Yes, you're right, forgot get_user_model
was added in 1.5.
Changed as you suggested.
Thanks @tonjo!
You're welcome. Sorry for the little mess, still quite new at github.
On 6 November 2013 18:05, Matt Luongo notifications@github.com wrote:
Thanks @tonjo https://github.com/tonjo!
— Reply to this email directly or view it on GitHubhttps://github.com/scholrly/neo4django/pull/217#issuecomment-27892216 .
No worries, you'll get the hang of it :)
Using
authenticate
gave alwaysgraph_auth.User
. Taken from django's auth,get_user_model
will ensure your ownAUTH_USER_MODEL
is returned instead.