diff --git a/dal/forms.py b/dal/forms.py index d4bc028..0968601 100644 --- a/dal/forms.py +++ b/dal/forms.py @@ -4,18 +4,18 @@ from django.utils.translation import ugettext_lazy as _ class LoginForm(forms.Form): - email = forms.CharField(widget=forms.TextInput()) + username = forms.CharField(widget=forms.TextInput()) password = forms.CharField(widget=forms.PasswordInput()) class Meta: - fields = ['email', 'password'] + fields = ['username', 'password'] def clean(self): - email = self.cleaned_data.get('email') + username = self.cleaned_data.get('username') password = self.cleaned_data.get('password') if self.errors: return self.cleaned_data - is_auth = authenticate(username=email, password=password) + is_auth = authenticate(username=username, password=password) if not is_auth: raise forms.ValidationError( _("Your username and/or password were incorrect.") @@ -26,6 +26,6 @@ class LoginForm(forms.Form): # ) return self.cleaned_data - def clean_email(self): - email = self.cleaned_data.get('email') - return email + def clean_username(self): + username = self.cleaned_data.get('username') + return username diff --git a/dal/views.py b/dal/views.py index eb5e5de..3f04ca2 100644 --- a/dal/views.py +++ b/dal/views.py @@ -37,9 +37,9 @@ class Index(FormView): success_url = 'useroptions.html' def form_valid(self, form): - email = form.cleaned_data.get('email') + username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') - user = authenticate(username=email, password=password) + user = authenticate(username=username, password=password) if user is not None: login(self.request, user) return render(self.request, 'useroptions.html', { 'user': user } )