Django form not valid - not null constraint - python

I have been looking at this issue for quite a while now. My form just keeps being invalid.
model.py
class GroupMember(models.Model):
Groupname = models.ForeignKey(DareGroups, on_delete=models.CASCADE)
Username = models.ForeignKey(DareUser, on_delete=models.CASCADE)
IsAdmin = models.BooleanField(default=False)
#receiver(post_save, sender=DareGroups)
def create_GroupAdmin(sender, instance, created, **kwargs):
if created:
GroupMember.objects.create(Groupname=instance,Username=get_current_authenticated_user().dareuser,IsAdmin=True)
#print(instance)
def __str__(self):
return self.Groupname.Groupname + "_"+self.Username.Username.username
view.py
def index(request):
if request.user.is_authenticated==True:
print('we zijn hier 1')
if request.method == "POST":
print('we zijn hier 2')
if 'newgroup' in request.POST:
formgroup = GroupsForm(request.POST)
if formgroup.is_valid():
print('komen we dan hier?')
formgroup.save()
return redirect('index')
elif 'newchallenge' in request.POST:
formchallenge = NewChallengeForm(request.POST)
if formchallenge.is_valid():
formchallenge.save()
return redirect('index')
elif 'addmember' in request.POST:
formaddmember=AddMemberToGroupForm(request.POST)
print('we zijn hier 3')
print(formaddmember.data)
if formaddmember.is_valid():
print('we zijn hier 4')
formaddmember.save()
else:
print('we zijn hier 5')
formaddmember.save()
print(formaddmember.errors)
return redirect('index')
else:
formgroup = GroupsForm()
formchallenge=NewChallengeForm()
formaddmember=AddMemberToGroupForm()
return render(request,"DareU/index.html",{'formgroup':formgroup,'formchallenge':formchallenge,'formaddmember':formaddmember})
else:
return render(request,"DareU/index.html")
forms.py
class AddMemberToGroupForm(forms.ModelForm):
class Meta:
model = GroupMember
fields = ('Groupname', 'Username','IsAdmin')
def __init__(self, user=None, **kwargs):
super(AddMemberToGroupForm, self).__init__(**kwargs)
self.fields['Groupname'].queryset = DareGroups.objects.filter(groupmember__IsAdmin=True)
HTML
<div class='container has-text-left' id="myForm3">
<h2 class="title is-2">Add member to group</h2>
<form method="POST" class="post-form">
{% csrf_token %}
{{ formaddmember.as_p }}
<button type="submit" class="button is-small is-success" name="addmember">Save</button>
<button type="button" class="button is-small is-danger cancel" onclick="closeForm3()">Close</button>
</form>
</div>
So, I can't get passed the is_valid check. If I do try to just save, I get the following error:
NOT NULL constraint failed: DareU_groupmember.Username_id
The form is rendering fine. I can select the correct values for both groupname and username, but it seems like when posting the form, the values are somehow lost.

I think it's because you're not passing *args to super() and if you're passing extra kwargs in, make sure to pop them before calling super().
def __init__(self, *args, **kwargs):
super(AddMemberToGroupForm, self).__init__(*args, **kwargs)
self.fields['Groupname'].queryset = DareGroups.objects.filter(groupmember__IsAdmin=True)

So Harben got me on the right path, to take a look at the init method.
It works after re-writing it like this:
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)
self.fields['Groupname'].queryset = DareGroups.objects.filter(groupmember__IsAdmin=True)

Related

Adding Google's reCAPTCHA a to a class-based view in Django

I want to add recaptcha for signup view in my Django app. This below uses decorators.py to achieve that. I have tried other tutorials for adding reCAPTCHA also but does not seem working. Any idea why?
views.py
class signup_view(generic.CreateView):
form_class = RegisterForm
template_name = 'users/signup.html'
success_url = reverse_lazy('users:login')
def form_valid(self, form):
if self.request.recaptcha_is_valid:
form.save()
return render(self.request, 'users/login.html', self.get_context_data())
return render(self.request, 'users/signup.html', self.get_context_data())
urls.py
path("signup", check_recaptcha(signup_view.as_view()), name="signup"),
decorators.py
from django.conf import settings
from django.contrib import messages
import requests
def check_recaptcha(function):
def wrap(request, *args, **kwargs):
request.recaptcha_is_valid = None
if request.method == 'POST':
recaptcha_response = request.POST.get('g-recaptcha-response')
data = {
'secret': settings.GOOGLE_RECAPTCHA_SECRET_KEY,
'response': recaptcha_response
}
r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=data)
result = r.json()
if result['success']:
request.recaptcha_is_valid = True
else:
request.recaptcha_is_valid = False
messages.error(request, 'Invalid reCAPTCHA. Please try again.')
return function(request, *args, **kwargs)
wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap
signup.html
<div class="form">
<form method="POST">
{% csrf_token %}
{{ form|crispy }}
<br>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="6LfzEg8gAAAAABcVpBvOjuLjs787K8_4Fu0N2wgu"></div>
<input type="submit" value="Sign Up">
</form>
</div>
Change your decorator to:
def wrap(request, *args, **kwargs):
request.recaptcha_is_valid = None
def wrap(obj, *args, **kwargs):
request = obj.request
request.recaptcha_is_valid = None
....
return function(obj, *args, **kwargs)
so it can works with django views.
In view put it before form_valid:
#check_recaptcha
def form_valid(self, form):

How to show data already on the database in a update form in Django?

I currently have a form that successfully updates both the model Userand Client.
The only thing I want it also to do is, when accessing the update page, that the form already have the current information (like we can do with placeholders, but actually editable data) so that the client can edit what he needs.
I also wonder if there is a way of updating only the changed fields or if it must update everything, even if it is the same.
This is my form:
class UpdateClient(ModelForm):
address = forms.CharField(max_length=200, label="Morada", widget=forms.TextInput(attrs={'class': 'form-control'}))
nif = forms.CharField(max_length=9, label="NIF", validators=[RegexValidator(r'^\d{1,10}$')], widget=forms.TextInput(attrs={'class': 'form-control'}))
mobile = forms.CharField(max_length=9, label="Telemóvel", validators=[RegexValidator(r'^\d{1,10}$')], widget=forms.TextInput(attrs={'class': 'form-control'}))
def clean_nif(self):
nif = self.cleaned_data['nif'];
if Clients.objects.filter(nif=nif).exists(): raise forms.ValidationError("NIF já existente.")
return nif
def __init__(self, *args, **kwargs):
super(UpdateClient, self).__init__(*args, **kwargs)
self.fields['first_name'].widget = TextInput(attrs={'class': 'form-control'})
self.fields['last_name'].widget = TextInput(attrs={'class': 'form-control'})
self.fields['email'].widget = EmailInput(attrs={'class': 'form-control'})
class Meta:
model = User
fields = ('email','first_name','last_name', 'address', 'nif', 'mobile')
And this is my views.py:
def client_det(request, nif):
ls= Clients.objects.get(nif=nif)
if request.method == 'POST':
form = UpdateClient(request.POST, instance=ls.user)
if form.is_valid():
user = form.save()
user.refresh_from_db()
user.clients.address = form.cleaned_data.get('address')
user.clients.nif = form.cleaned_data.get('nif')
user.clients.mobile = form.cleaned_data.get('mobile')
user.clients.save()
return redirect('clients')
else:
form = UpdateClient()
return render(request, 'backend/client_detail.html', {'form': form, 'ls': ls})
And my client_detail.html
<form method="post">
{% csrf_token %}
<!-- Address -->
<h6 class="heading-small text-muted mb-4">Dados Cliente</h6>
<div class="pl-lg-4">
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label class="form-control-label" for="input-first-name">Primeiro Nome</label>
{{form.first_name}}
</div>
(...)
When instantiating the form, supply the instance for the GET branch, the same as you do in the POST branch.
def client_det(request, nif):
ls= Clients.objects.get(nif=nif)
if request.method == 'POST':
form = UpdateClient(request.POST, instance=ls.user)
...
else:
form = UpdateClient(instance=ls.user)
return render(request, 'backend/client_detail.html', {'form': form, 'ls': ls})
Edit:
I missed the part of your question where you also need the client information set.
I think for that you could either do it in the __init__ function on the form or pass the values through the initial parameter.
Example 1:
def __init__(*args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance:
self.fields['nif'] = self.instance.clients.nif
...
Example 2:
form = UpdateClient(instance=ls.user, initial={"nif": ls.user.clients.nif, ...})

How set initial values to fields on form?

enter code hereI'm having some problems to solve a problem. I have a template, which allows the user to change some of their account settings. My goal is to initialize the form, with the user's default values, and he can keep or change them (by after submit form). However, until now the page does not render these values. I'm using a class based view, CreateView, for this purpose.
My code is listed below.
Here, is my CreateView.
class DetailUserInfoView(LoginRequiredMixin ,CreateView):
model = CustomUser.CustomUser
template_name = 'users/InfoUser.html'
login_url = settings.LOGOUT_REDIRECT_URL
context_object_name = 'user'
form_class = CustomUserChangeForm
def get_object(self):
self.model = self.request.user
return self.model
def get_initial(self):
initial = super(DetailUserInfoView, self).get_initial()
initial = initial.copy()
initial[config.USERNAME] = self.request.user.username
initial[config.FIRST_NAME] = self.request.user.first_name
initial[config.LAST_NAME] = self.request.user.last_name
return initial
def get_form_kwargs(self):
kwargs = {'initial': self.get_initial()}
return kwargs
def get_context_data(self, **kwargs): #GET OBJECT ACTS AFTER THAN GET_OBJECT --> EXAMPLE OF GET_CONTEXT_DATA, I DIDN'T NEED THIS
context = super(DetailUserInfoView, self).get_context_data(**kwargs)
context['username'] = self.request.user.username
return context
Here the form.
class CustomUserChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = CustomUser.CustomUser
fields = ('email', 'password', 'first_name', 'last_name', 'username', 'userType')
And finally an extract of template.
<div id="infoMayOverride">
<form class="getOverridedValues" method="post">
{% csrf_token %}
<div id="usernameData">
<label>{{ form.username.label_tag }}</label> <!--MODEL ON CREATEUSERVIEW IS CUSTOMUSER, AND NOW I NEED TO USE THIS FIELDS AND INHERITED FIELDS FROM USER CLASS-->
<input type="text" id="usernameInput" value="{{ form.username }}">
</div>
<div id="firstNameData">
<label>{{ form.first_name.label_tag }}</label>
<input type="text" id="firstNameInput" value="{{ form.first_name }}">
</div>
<div id="lastNameData">
<label>{{ form.last_name.label_tag }}</label>
<input type="text" id="lastNameInput" value="{{ form.last_name }}">
</div>
<div id="divBtnChangeProfile">
<input type="submit" class="btnChangeProfile" value="Atualizar Profile">
</div>
</form>
</div>
I'd appreciate it if you could help me. I am new to the Django environment, and have tried many approaches, and I have not yet been able to solve this problem.
--------------------------- Update ------------------------------------
Now, i can get initial values. But to view them i need to write on input form: form.username.initial, and with this i can't after submit form to update user values.
Anyone knows how to solve this type of problem??
I finally got this problem solved. I will make my solution available, since it can help other people.
I had to make some changes to the code I provided behind.
Below is the code of view.
class DetailUserInfoView(LoginRequiredMixin, UpdateView):
model = CustomUser.CustomUser
template_name = 'users/InfoUser.html'
login_url = settings.LOGOUT_REDIRECT_URL
context_object_name = 'user'
form_class = CustomUserChangeForm
def get_object(self, queryset=None):
return self.request.user
def get_form_kwargs(self):
kwargs = super(DetailUserInfoView, self).get_form_kwargs()
u = self.request.user
kwargs['username_initial'] = u.username
kwargs['fName_initial'] = u.first_name
kwargs['lName_initial'] = u.last_name
return kwargs
def get_context_data(self, **kwargs): #GET OBJECT ACTS AFTER THAN GET_OBJECT --> EXAMPLE OF GET_CONTEXT_DATA, I DIDN'T NEED THIS
context = super(DetailUserInfoView, self).get_context_data(**kwargs)
form_class = self.get_form_class()
form = self.get_form(form_class)
context['form'] = form
return context
My form (with init function, to set initial values on form, and is called by def get_form_kwargs(self)).
class CustomUserChangeForm(UserChangeForm):
def __init__(self, *args, **kwargs):
username_initial = kwargs.pop('username_initial', None)
fName_initial = kwargs.pop('fName_initial', None)
lName_initial = kwargs.pop('lName_initial', None)
super(CustomUserChangeForm, self).__init__(*args, **kwargs)
self.fields['username'].initial = username_initial
self.fields['first_name'].initial = fName_initial
self.fields['last_name'].initial = lName_initial
class Meta(UserChangeForm.Meta):
model = CustomUser.CustomUser
fields = ('username', 'email', 'first_name', 'last_name')
And finnaly, in template I replace the tag input with {{ form.username }}.
I hope it can help someone who has the same problem.

Can't Add/Accept and Decline/Cancel Friend requests on Django

Able to Send Friend requests successfully but responding to the requests are an issue. When you press Accept to Add, the button is removed but the Friend isn't added or when you press Cancel to Decline, nothing happens.
Tried adding a forms
class Add_Friend(forms.ModelForm):
model = UserProfile
def add_friend(request, user_profile):
request.notification_set.get(type=Notification.FRIEND_REQUEST, sender=user_profile.user.username).delete()
request.friends.add(user_profile)
user_profile.friends.add(self)
request.friend_requests.remove(user_profile)
noti = Notification.objects.create(owner=user_profile, type=Notification.ACCEPTED_FRIEND_REQUEST, sender=self.user.username)
user_profile.notification_set.add(noti)
return self.friends.count()
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
first_name = models.CharField(blank=True, max_length=128)
friends = models.ManyToManyField('self', blank=True, related_name='friends')
friend_requests = models.ManyToManyField('self', blank=True, related_name='friend_requests')
def send_friend_request(self, user_profile):
self.friend_requests.add(user_profile)
noti = Notification.objects.create(owner=self, type=Notification.FRIEND_REQUEST, sender=user_profile.user.username)
self.notification_set.add(noti)
return self.friend_requests.count()
def add_friend(self, user_profile):
self.friend_requests.remove(user_profile)
self.notification_set.get(type=Notification.FRIEND_REQUEST, sender=user_profile.user.username).delete()
self.friends.add(user_profile)
user_profile.friends.add(self)
noti = Notification.objects.create(owner=user_profile, type=Notification.ACCEPTED_FRIEND_REQUEST, sender=self.user.username)
user_profile.notification_set.add(noti)
return self.friends.count()
def cancel_friend_request(self, user_profile):
self.friend_requests.remove(user_profile)
self.notification_set.get(type=Notification.FRIEND_REQUEST, sender=user_profile.user.username).delete()
noti = Notification.objects.create(owner=user_profile, type=Notification.DECLINED_FRIEND_REQUEST, sender=self.user.username)
user_profile.notification_set.add(noti)
return self.friend_requests.count()
def __str__(self):
return self.get_first_name()
#Takes you to the userprofile page
def get_absolute_url(self):
return "/users/{}".format(self.id)
#method_decorator(login_required, name='dispatch')
class SendFriendRequestView(View):
def get(self, request, *args, **kwargs):
profile_id = request.GET.get('profile_id')
requester_id = request.GET.get('requester_id')
target = UserProfile.objects.get(id=profile_id)
requester = UserProfile.objects.get(id=requester_id)
target.send_friend_request(requester)
message = 'Friend request to {} sent!'.format(target.visible_name)
messages.info(request, message)
return redirect('profile', username=target.user.username)
#method_decorator(login_required, name='dispatch')
class CancelFriendRequestView(View):
def cancel_friend_request(request, id):
if request.user.is_authenticated():
user = get_object_or_404(User, id=id)
frequest, created = FriendRequest.objects.filter(
from_user=request.user,
to_user=user).first()
frequest.delete()
return HttpResponseRedirect('/users')
#method_decorator(login_required, name='dispatch')
class AddFriendView(View):
def get(self, request, *args, **kwargs):
try:
profile_id = request.GET.get('profile_id')
requester_id = request.GET.get('requester_id')
target = UserProfile.objects.get(id=profile_id)
requester = UserProfile.objects.get(id=requester_id)
target.add_friend(requester)
message = 'Added friend {}!'.format(target.visible_name)
messages.info(request, message)
return redirect('friends', username=target.user.username)
except Exception as e:
print('Error: {}'.format(e))
url(r'^friend-request/send/(?P<id>[\w\-]+)/$', send_friend_request),
url(r'^friend-request/cancel/(?P<id>[\w\-]+)/$', cancel_friend_request),
url(r'^friend-request/accept/(?P<id>[\w\-]+)/$', accept_friend_request),
{% if user.userprofile in userprofile.friends.all %}
<form>
<button id="remove_friend" data-requesterid="{{user.userprofile.id}}" data-profileid="{{userprofile.id}}">
Remove friend
</button>
</form>
{% elif user.userprofile in userprofile.friend_requests.all %}
Friend request pending...
<form>
<button id="cancel_friend_request " data-requesterid="{{user.userprofile.id}}" data-profileid="{{userprofile.id}}">
Cancel
</button>
</form>
{% else %}
<form>
<button id="send_friend_request" data-requesterid="{{user.userprofile.id}}" data-profileid="{{userprofile.id}}">
Send friend request
</button>
</form>
{% endif %}
I'd like the User to be able to Accept/Decline Friend Requests.

Django form Validation error not showing up also the form is not authenticating

Outcome needed : My main aim is to get a guest login that is user adds email address and then django checks for the email in the database if it finds one then error is shown else user is logged in.
Problem : In my form when I add an email address then Django adds the email in the database but if I add that email again no error is shown also I am not being logged in Django.
Version Using:
appdirs==1.4.2
cffi==1.9.1
cryptography==1.7.2
Django==1.8.4
django-crispy-forms==1.6.1
django-registration-redux==1.4
enum34==1.1.6
idna==2.4
ipaddress==1.0.18
olefile==0.44
packaging==16.8
Pillow==4.0.0
pyasn1==0.2.3
pycparser==2.17
pyOpenSSL==16.2.0
pyparsing==2.1.10
requests==2.13.0
six==1.10.0
forms.py
from django import forms
from django.contrib.auth import get_user_model
User = get_user_model()
class GuestCheckoutForm(forms.Form):
email = forms.EmailField()
email2 = forms.EmailField(label='Verify Email')
def clean_email2(self):
email = self.cleaned_data.get("email")
email2 = self.cleaned_data.get("email2")
if email == email2:
user_exists = User.objects.filter(email=email).count()
if user_exists != 0:
raise forms.ValidationError("This User already exists. Please login instead.")
return email2
else:
raise forms.ValidationError("Please confirm emails are the same")
views.py
from django.contrib.auth.forms import AuthenticationForm
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404, JsonResponse
from django.shortcuts import render, get_object_or_404, redirect
from django.views.generic.base import View
from django.views.generic.detail import SingleObjectMixin, DetailView
from django.views.generic.edit import FormMixin
# Create your views here.
from orders.forms import GuestCheckoutForm
from orders.models import UserCheckout
from products.models import Variation
from .models import Cart, CartItem
class ItemCountView(View):
def get(self, request, *args, **kwargs):
if request.is_ajax():
cart_id = self.request.session.get("cart_id")
if cart_id == None:
count = 0
else:
cart = Cart.objects.get(id=cart_id)
count = cart.items.count()
request.session["cart_item_count"] = count
return JsonResponse({"count": count})
else:
raise Http404
class CartView(SingleObjectMixin, View):
model = Cart
template_name = "carts/view.html"
def get_object(self, *args, **kwargs):
self.request.session.set_expiry(0) #5 minutes
cart_id = self.request.session.get("cart_id")
if cart_id == None:
cart = Cart()
cart.save()
cart_id = cart.id
self.request.session["cart_id"] = cart_id
cart = Cart.objects.get(id=cart_id)
if self.request.user.is_authenticated():
cart.user = self.request.user
cart.save()
return cart
def get(self, request, *args, **kwargs):
cart = self.get_object()
item_id = request.GET.get("item")
delete_item = request.GET.get("delete", False)
item_added = False
if item_id:
item_instance = get_object_or_404(Variation, id=item_id)
qty = request.GET.get("qty", 1)
try:
if int(qty) < 1:
delete_item = True
except:
raise Http404
cart_item, created = CartItem.objects.get_or_create(cart=cart, item=item_instance)
if created:
item_added = True
if delete_item:
cart_item.delete()
else:
cart_item.quantity = qty
cart_item.save()
if not request.is_ajax():
return HttpResponseRedirect(reverse("cart"))
#return cart_item.cart.get_absolute_url()
if request.is_ajax():
try:
total = cart_item.line_item_total
except:
total = None
try:
subtotal = cart_item.cart.subtotal
except:
subtotal = None
try:
cart_total = cart_item.cart.total
except:
cart_total = None
try:
tax_total = cart_item.cart.tax_total
except:
tax_total = None
try:
total_items = cart_item.cart.items.count()
except:
total_items = 0
data = {
"deleted": delete_item,
"item_added": item_added,
"line_total": total,
"subtotal": subtotal,
"cart_total": cart_total,
"tax_total": tax_total,
"total_items": total_items
}
return JsonResponse(data)
context = {
"object": self.get_object()
}
template = self.template_name
return render(request, template, context)
class CheckoutView(FormMixin, DetailView):
model = Cart
template_name = "carts/checkout_view.html"
form_class = GuestCheckoutForm
def get_object(self, *args, **kwargs):
cart_id = self.request.session.get("cart_id")
if cart_id == None:
return redirect("cart")
cart = Cart.objects.get(id=cart_id)
return cart
def get_context_data(self, *args, **kwargs):
context = super(CheckoutView, self).get_context_data(*args, **kwargs)
user_can_continue = False
user_check_id = self.request.session.get("user_checkout_id")
if not self.request.user.is_authenticated() or user_check_id == None:# or if request.user.is_guest:
context["login_form"] = AuthenticationForm()
context["next_url"] = self.request.build_absolute_uri()
elif self.request.user.is_authenticated() or user_check_id != None:
user_can_continue = True
else:
pass
context["user_can_continue"] = user_can_continue
context["form"] = self.get_form()
return context
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
if form.is_valid():
email = form.cleaned_data.get("email")
user_checkout, created = UserCheckout.objects.get_or_create(email=email)
request.session["user_checkout_id"] = user_checkout.id
print user_checkout
return self.form_valid(form)
else:
return self.form_invalid(form)
def get_success_url(self):
return reverse("checkout")
checkout_view.html
{% extends "base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
{% if not user_can_continue %}
<div class='col-sm-6'>
<p class='lead'>Continue as Guest</p>
<form method='POST' action=''>{% csrf_token %}
{{ form|crispy }}
<input type='submit' class='btn btn-success' value='Continue as Guest' />
</form>
</div>
<div class='col-sm-6'>
<p class='lead'>Login to Continue</p>
<form method='POST' action="{% url 'auth_login' %}"> {% csrf_token %}
{{ login_form|crispy }}
<input type='hidden' name='next' value='{{ next_url }}' />
<input type='submit' class='btn btn-success' value='Login' />
</form>
<p class='text-center'>
<p>{% trans "Forgot password" %}? {% trans "Reset it" %}!</p>
<p>{% trans "Not member" %}? {% trans "Register" %}!</p>
</p>
</div>
{% endif %}
{% endblock %}
models.py
from django.conf import settings
from django.db import models
# Create your models here.
class UserCheckout(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True, blank=True) #not required
email = models.EmailField(unique=True) #--> required
def __unicode__(self): #def __str__(self):
return self.email
As such I am getting no error but the problems stated above are occurring
The clean_* methods in django should always return the value.
def clean_email2(self):
email = self.cleaned_data.get("email")
email2 = self.cleaned_data.get("email2")
if email == email2:
# Query your UserCheckout model. Not the auth one!
if UserCheckout.objects.filter(email=email).exists():
raise forms.ValidationError("This User already exists. Please login instead.")
else:
raise forms.ValidationError("Please confirm emails are the same")
return email2

Categories