23 lines
761 B
Python
23 lines
761 B
Python
from django import forms
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.auth.forms import UserCreationForm
|
|
|
|
class SignupForm(UserCreationForm):
|
|
email = forms.EmailField(required=True, help_text="Required. A valid email address.")
|
|
terms_accepted = forms.BooleanField(
|
|
required=True,
|
|
label="I accept the standard terms and conditions",
|
|
widget=forms.CheckboxInput(attrs={'class': 'form-check-input'})
|
|
)
|
|
|
|
class Meta(UserCreationForm.Meta):
|
|
model = User
|
|
fields = UserCreationForm.Meta.fields + ('email',)
|
|
|
|
def save(self, commit=True):
|
|
user = super().save(commit=False)
|
|
user.email = self.cleaned_data["email"]
|
|
if commit:
|
|
user.save()
|
|
return user
|