html语言 怎么清除用户名 name= password=,在html页面中填写注册表单后,它会给出这个错误,并使用用户名和密码并将值存储在登录表单中...
在html頁面中填寫注冊表單后,它會給出此錯誤,并使用用戶名和密碼并將值存儲在登錄表單中:TypeError at /login/ argument of type 'NoneType' is not iterable.
模型.py:
^{pr2}$
表單.py:from django import forms
from .models import signup
from .models import login
class loginForm(forms.ModelForm):
password=forms.CharField(widget=forms.PasswordInput())
class Meta:
model=login
fields=['username','password']
class SignUpForm(forms.ModelForm):
password=forms.CharField(widget=forms.PasswordInput())
class Meta:
model=signup
fields=['username','full_name', 'email','department','password','pic']
視圖.py:from django.shortcuts import render
from .forms import SignUpForm
from .forms import loginForm
from django.db import connection
def home(request):
title= 'welcome'
form = SignUpForm(data = request.POST or None)
print(form.is_valid)
if form.is_valid():
instance = form.save(commit=False)
instance.save()
print(instance)
print(instance.email)
context = {
"title": title,
"form": form,
}
return render(request,"base.html", context)
def login(request):
form = loginForm(data = request.POST or None)
if form.is_valid():
instance = form.save(commit=False)
username=instance.username
password=instance.password
row=auth(username,password)
if password in row:
instance.save()
form1=SignUpForm
context={
"form":form1,
"instance":instance
}
return render(request, "profile.html", context)
title= 'welcome back'
context ={
"title":title,
"form":form
}
return render(request, "login.html", context)
def auth(username,password):
cursor = connection.cursor()
cursor.execute("SELECT password FROM teacher_signup WHERE username = %s", [username])
row = cursor.fetchone()
return row
當單擊“注冊”按鈕[如果密碼在第行:]時,將以某種方式調用此行。在
總結
以上是生活随笔為你收集整理的html语言 怎么清除用户名 name= password=,在html页面中填写注册表单后,它会给出这个错误,并使用用户名和密码并将值存储在登录表单中...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html 搜索框 自动补全,自动完成的搜
- 下一篇: 2021年东港二中高考成绩查询,辽宁省东