I have a custom minimal user model subclassing AbstractBaseUser, containing 
little more than an email address, for use with django-social-auth. 
However, I'm using an externally-developed app which queries the user model 
using the username field, which in my case does not exist, resulting in a 
FieldError. Rather than modifying the external app, it would be nicer to 
handle this within the User model. While the AbstractBaseUser model does 
call for specifying which field is the username with the USERNAME_FIELD 
property, it doesn't actual allow referencing that field as 'username' in a 
query. 

I've managed to work around this by using a custom queryset as per 
http://stackoverflow.com/questions/17250776/using-an-alias-or-property-in-place-of-a-field-in-django
 
but this seems quite a long-winded way around this.

I'm guessing this case is not unique in apps assuming the presence of a 
field 'username' which the app can use as a unique way of identifying the 
user. Is there a new way (in django 1.5+) that apps should be trying to 
access users? Could django be modified to include so that AbstractBaseUsers 
include a 'virtual' field 'username' which is an alias to whatever 
USERNAME_FIELD references?

Cheers,

Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to