例如,在我的数据库中,有一个名为BlackList的表,如下所示:
该表的型号为:
class BlackList(models.Model):
name = models.CharField(max_length=1000, null=True, blank=True)
flag1 = models.BooleanField(default=False)
flag2 = models.BooleanField(default=False)
我想做的是这样的:
if request.method == "POST":
username = request.POST.get('username') # Get username input first
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
# BLname = Read the username from the table
# BLflag1 = read the Flag1 for the user
# BLflag2 = read the Flag2 for the user
if BLflag1 == True and BLflag2 == True:
something will happen
elif BLflag1 == True and BLflag2 == False:
something will happen
else:
# set the Flag1 and Flag2 of this user to True.
所以,我的问题是
您应该首先检查用户是否经过身份验证
相关问题 更多 >
编程相关推荐