SHARE
TWEET

Untitled

a guest May 27th, 2018 283 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Users(models.Model):
  2.     username = models.CharField(max_length=255)
  3.     slug = models.CharField(max_length=255, default='0')
  4.     password = models.CharField(max_length=300)
  5.     password_token = models.CharField(max_length=300, default='0')
  6.     email = models.CharField(max_length=255)
  7.     email_verified = models.BooleanField(default=False)
  8.     email_token = models.CharField(max_length=255)
  9.     email_token_expiry = models.DateTimeField()
  10.     tos = models.BooleanField(default=False)
  11.     active = models.BooleanField(default=False)
  12.     last_login = models.DateTimeField(auto_now_add=True)
  13.     last_action = models.DateTimeField(auto_now_add=True)
  14.     is_admin = models.BooleanField(default=False)
  15.     role = models.CharField(max_length=255, default='0')
  16.     created = models.DateTimeField(auto_now_add=True)
  17.     modified = models.DateTimeField(auto_now_add=True)
  18.  
  19.     def __unicode__(self):
  20.         return self.username
  21.  
  22. class UsersModelForm(forms.ModelForm):
  23.  
  24.     def __init__(self, *args, **kwargs):
  25.         super(UsersModelForm, self).__init__(*args, **kwargs)
  26.         self.fields.keyOrder = ['username', 'password', 'passwordrepeat', 'email']
  27.  
  28.     passwordrepeat = forms.CharField(max_length=300, widget=forms.PasswordInput, label=u'Repeat Password')
  29.  
  30.     class Meta:
  31.         model = Users
  32.         widgets = {
  33.             'password' : forms.PasswordInput(),
  34.         }
  35.  
  36.     def clean(self):
  37.         cleaned_data = self.cleaned_data
  38.         password = cleaned_data.get("password")
  39.         passwordrepeat = cleaned_data.get("passwordrepeat")
  40.         if password != passwordrepeat:
  41.             raise forms.ValidationError("Passwords must match.")
  42.  
  43.         return cleaned_data
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top