Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person(User):
- MALE = 'M'
- FEMALE = 'F'
- GENDER = (
- (MALE, 'Male'),
- (FEMALE, 'Female'),
- )
- birth_date = models.DateField()
- gender = models.CharField(max_length = 1, choices = GENDER)
- class SignupForm(ModelForm):
- MALE = 'M'
- FEMALE = 'F'
- GENDER = (
- (MALE, 'Male'),
- (FEMALE, 'Female'),
- )
- thisYear = date.today().year
- YEARS = [thisYear - year for year in range(100)]
- password = forms.CharField(widget = forms.PasswordInput(), min_length=5, max_length = 128)
- birth_date = forms.DateField(widget=extras.SelectDateWidget(years = YEARS), initial='1990-01-01')
- gender = forms.ChoiceField(choices = GENDER, initial='M')
- class Meta:
- model = Person
- exclude = ('last_name', 'is_staff', 'is_active', 'is_superuser', 'last_login', 'date_joined', 'user_permissions', 'groups', 'attraction' )
- #all fields in this list will map to a specific model attribute and will be comitted to the database
- fields = ('username', 'password', 'first_name', 'email', 'gender', 'birth_date')
- user = models.OneToOneField(User)
- blah =
- .
- .
- if form.is_valid():
- user = User.objects.create_user(username = form.cleaned_data['username'],
- email = form.cleaned_data['email'],
- password = form.cleaned_data['password'],
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement