Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. from django import forms
  2. from registration.forms import RegistrationForm
  3. from django.utils.translation import ugettext_lazy as _
  4. from yourapp.models import SampleProfile
  5. from registration.models import RegistrationProfile
  6.  
  7. attrs_dict = { 'class': 'required' }
  8.  
  9.  
  10. class RegistrationFormZ(RegistrationForm):
  11.   middle_name = forms.CharField(widget=forms.TextInput(attrs=attrs_dict))
  12.  
  13.   def save(self, profile_callback=None):
  14.     new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
  15.                                                                 password=self.cleaned_data['password1'],
  16.                                                                 email=self.cleaned_data['email'])
  17.     new_profile = SampleProfile(user=new_user, user_middle_name=self.cleaned_data['middle_name'])
  18.     new_profile.save()
  19.  
  20.     return new_user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement