-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added password and username instruction, added error messages
- Loading branch information
1 parent
8a0a80c
commit bca295f
Showing
3 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from userauths.models import User | ||
from django.core.exceptions import ValidationError | ||
|
||
|
||
class UserRegisterForm(UserCreationForm): | ||
email = forms.EmailField() | ||
|
||
class Meta: | ||
model = User | ||
fields = ['username', 'email', 'password1', 'password2'] | ||
|
||
def clean_username(self): | ||
username = self.cleaned_data.get('username') | ||
if len(username) < 6: | ||
raise ValidationError("Username must be at least 6 characters long.") | ||
return username |