【发布时间】:2019-08-29 10:03:58
【问题描述】:
型号:
class authentifier(models.Model):
matricule =models.CharField(max_length=254, blank=True, null=True)
password = models.CharField(max_length=254, blank=True, null=True)
nom =models.CharField(max_length=254, blank=True, null=True)
prenom=models.CharField(max_length=254, blank=True, null=True)
statut = models.CharField(max_length=254, blank=True, null=True)
验证码forms.py:
from django import forms
class UserLoginForm(forms.Form):
print(666)
matricule = forms.CharField(required=True , widget=forms.TextInput)
password = forms.CharField(required=True , widget= forms.PasswordInput)
模板html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width , initial-
scales=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>
<body>
<form>
<form method="POST">
{% csrf_token %}
<tr><th><label for="id_matricule">Matricule:</label></th><td><input
type="text" name="matricule" id="Matricule"></td></tr>
<tr><th><label for="id_password">Password:</label></th><td><input
type="password" name="password" id="password"></td></tr>
<input type="submit" value="Se Connecter">
</form>
</body>
</html>
我发现 form.is_valid() = false - 但我不知道如何得到原因 WHY...
我需要使用矩阵和密码进行身份验证
【问题讨论】:
-
查看代码在哪里?还有为什么你的 HTML 中有 2 个
标签: python django authentication