Hi,

My custom user model requires unique email addresses, which are the users' 
identifiers.

My user registration modelform works great.  If a user tries to register 
with an email that is already in the system, the form fails to validate and 
the 'unique' invalid message is displayed back to the user.

I am trying to create an authentication modelform based on the same user 
model.  When I try to authenticate a registered user, the email field 
throws the unique validation error.  How can I overwrite this property? 
 I've tried:

class MyUserModel(AbstractBaseUser):
    """
    Custom User Model requires unique email address.
    """
    # email field
    email = models.EmailField(
        unique=True,
        error_messages={
            'invalid': "You must enter a valid email address.",
            'unique': "Your email address is already in our system!"
        }
    )

class MyAuthForm(forms.ModelForm):
    """
    Form for authenticating users.
    """
    def __init__(self, *args, **kwargs):
        super(MyAuthForm, self).__init__(*args, **kwargs)
        self.Meta.model.email.unique = True

I've tried a few variations on this with no luck.  Any ideas?

Thanks!
  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/32f415a0-99e2-461b-8dca-44c0ea98ce93%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to