Skip to content

Commit

Permalink
prevent user to submit empty email in UserUpdateView
Browse files Browse the repository at this point in the history
  • Loading branch information
mohi7solanki committed Nov 5, 2017
1 parent a723821 commit 6804ed5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ class SignUpForm(UserCreationForm):
class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')


class UserInformationUpdateForm(forms.ModelForm):
email = forms.EmailField()
class Meta:
model = User
fields = ('first_name', 'last_name', 'email', )
5 changes: 2 additions & 3 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils.decorators import method_decorator
from django.views.generic import UpdateView

from .forms import SignUpForm
from .forms import SignUpForm, UserInformationUpdateForm


def signup(request):
Expand All @@ -23,8 +23,7 @@ def signup(request):

@method_decorator(login_required, name='dispatch')
class UserUpdateView(UpdateView):
model = User
fields = ('first_name', 'last_name', 'email', )
form_class = UserInformationUpdateForm
template_name = 'my_account.html'
success_url = reverse_lazy('my_account')

Expand Down

0 comments on commit 6804ed5

Please sign in to comment.