form.py
class SignUpForm(forms.Form):
name = forms.CharField(max_length=50, required=True)
email = forms.EmailField(max_length=100, required=True)
password = forms.CharField(max_length=20, required=True)
class SignInForm(forms.Form):
email = forms.EmailField()
password = forms.CharField(max_length=20, min_length=8)
view.py
def Sign_Up(request):
if request.method == 'POST':
form = SignUpForm(request)
if form.is_valid():
cd = form.cleaned_data
name = cd['name']
email = cd['email']
password = cd['password']
us = User.objects.all()
us = User(name=name, email=email, password=password)
us.save()
return HttpResponseRedirect('/')
else:
form = SignUpForm()
return render(request,'User Login Page.html', {'form':form})
def Sign_In(request):
if request.method =='POST' :
form = SignInForm(request)
if form.is_valid():
F = form.cleaned_data
Eemail = F['email']
Epassword = F['password']
try:
user = User.objects.filter(email=Eemail)
except User.DoesNotExist:
form = SignInForm()
return render(request, "Admin Login Page.html", {'form': form})
if User.password == Epassword:
return HttpResponseRedirect("/")
form = SignInForm()
return render(request,"Admin Login Page.html",{'form':form})
I'm new in Django I want to make sign in & up for my site with Django but it doesn't work!
when i click on submit button my sign up directly go to address on HttpRsponseDirect even with empty parameters
Aucun commentaire:
Enregistrer un commentaire