Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Users(models.Model):
- username = models.CharField(max_length=255)
- slug = models.CharField(max_length=255, default='0')
- password = models.CharField(max_length=300)
- password_token = models.CharField(max_length=300, default='0')
- email = models.CharField(max_length=255)
- email_verified = models.BooleanField(default=False)
- email_token = models.CharField(max_length=255)
- email_token_expiry = models.DateTimeField()
- tos = models.BooleanField(default=False)
- active = models.BooleanField(default=False)
- last_login = models.DateTimeField(auto_now_add=True)
- last_action = models.DateTimeField(auto_now_add=True)
- is_admin = models.BooleanField(default=False)
- role = models.CharField(max_length=255, default='0')
- created = models.DateTimeField(auto_now_add=True)
- modified = models.DateTimeField(auto_now_add=True)
- def __unicode__(self):
- return self.username
- class UsersModelForm(forms.ModelForm):
- def __init__(self, *args, **kwargs):
- super(UsersModelForm, self).__init__(*args, **kwargs)
- self.fields.keyOrder = ['username', 'password', 'passwordrepeat', 'email']
- passwordrepeat = forms.CharField(max_length=300, widget=forms.PasswordInput, label=u'Repeat Password')
- class Meta:
- model = Users
- widgets = {
- 'password' : forms.PasswordInput(),
- }
- def clean(self):
- cleaned_data = self.cleaned_data
- password = cleaned_data.get("password")
- passwordrepeat = cleaned_data.get("passwordrepeat")
- if password != passwordrepeat:
- raise forms.ValidationError("Passwords must match.")
- return cleaned_data
Add Comment
Please, Sign In to add comment