arrowcounter/user/forms.py

22 lines
689 B
Python
Raw Permalink Normal View History

from django.contrib.auth.forms import (UserCreationForm, UsernameField,
AuthenticationForm)
from django import forms
from django.contrib.auth.models import User
from django.conf import settings
from .models import CounterUser
class RegistrationForm(UserCreationForm):
email = forms.EmailField(label = "Email")
class Meta:
model = CounterUser
fields = ("username", "email", )
field_classes = {'username': UsernameField, 'email': forms.EmailField}
def save(self, commit=True):
2019-04-28 11:00:10 +00:00
user = super(RegistrationForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
if commit:
user.save()
return user