<s> from django . db import models <EOL> from django . forms import ModelForm , TextInput , Textarea , SelectMultiple , CheckboxSelectMultiple <EOL> from django . forms import EmailField <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . auth . forms import UserCreationForm <EOL> class UserProfile ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> user = models . OneToOneField ( User ) <EOL> class RegisterUserForm ( UserCreationForm ) : <EOL> class Meta : <EOL> model = User <EOL> fields = ( '<STR_LIT:username>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> labels = { '<STR_LIT:email>' : '<STR_LIT>' } <EOL> widgets = { <EOL> '<STR_LIT:username>' : TextInput ( attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT:email>' : TextInput ( attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) , <EOL> } <EOL> def save ( self , commit = True ) : <EOL> user = super ( RegisterUserForm , self ) . save ( commit = False ) <EOL> if self . cleaned_data [ "<STR_LIT:email>" ] : <EOL> user . email = self . cleaned_data [ '<STR_LIT:email>' ] <EOL> if commit : <EOL> user . save ( ) <EOL> return user </s>
