【发布时间】:2017-10-27 01:30:43
【问题描述】:
我的 Django 表单要求输入一个特定的数字(在本例中为 1345)。然而,如果用户键入其他数字,则会出现一条警告消息,指示允许的整数的上限/下限。如何防止这些特定的警告消息?对错误输入的响应应始终为:“错误”。实现这种行为的最简单方法是什么?
#models.py
class Player():
code = models.PositiveIntegerField(min=1345,max=1345)
#etc
#template.html
{% formfield player.code with label="What is the code?" %}
【问题讨论】:
-
将代码发布到您的表单中。