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): user = super(RegistrationForm, self).save(commit=False) user.email = self.cleaned_data["email"] if commit: user.save() return user