to achieve unique constraint (without repetition of default user models fields) on email-id I did this
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
# some extra fields
class Meta:
unique_together = ('email', )
and then in settings file AUTH_USER_MODEL = 'myApp.User'
mysql table shows both column(username and email) as UNI key.
so far looks good but when it comes to authentication I'm not sure where I'm making mistake. but its not working/loggin-in
this code works when username is the unique key and we login through username instead of email.
any help/leads would be appreciated.
EDIT: do i have to write custom modelBackend (explained here http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/) but not sure how, I see lots of code here https://github.com/django/django/blob/master/django/contrib/auth/init.py