Skip to content

Commit 88f40f9

Browse files
committed
Make email a required registration field
1 parent 5a2ab1a commit 88f40f9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

accounts/forms.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.contrib.auth.models import User
33
from django.contrib.auth.forms import UserCreationForm
44
from django.core.exceptions import ValidationError
5+
from .models import Profile
56

67

78
class UserLoginForm(forms.Form):
@@ -12,6 +13,7 @@ class UserLoginForm(forms.Form):
1213

1314
class UserRegistrationForm(UserCreationForm):
1415
"""Form to register new user"""
16+
email = forms.EmailField(max_length=75, required=True)
1517
password1 = forms.CharField(
1618
label="Password", widget=forms.PasswordInput)
1719
password2 = forms.CharField(
@@ -20,7 +22,10 @@ class UserRegistrationForm(UserCreationForm):
2022

2123
class Meta:
2224
model = User
23-
fields = ['email', 'username', 'password1', 'password2']
25+
help_texts = {
26+
'username': None
27+
}
28+
fields = ['username', 'email', 'password1', 'password2']
2429

2530
def clean_email(self):
2631
email = self.cleaned_data.get('email')
@@ -40,3 +45,9 @@ def clean_password2(self):
4045
raise ValidationError("Passwords must match.")
4146

4247
return password2
48+
49+
50+
class EditProfileForm(forms.ModelForm):
51+
class Meta:
52+
model = Profile
53+
fields = ('image',)

0 commit comments

Comments
 (0)