每次我在Django的Admin部分中输入新播放器时,都会收到一条错误消息,提示“此字段为必填字段。”。
有没有一种方法可以使不需要创建自定义表单的字段成为必填字段?我可以在models.py或admin.py中执行此操作吗?
这是我在models.py中的类的样子。
class PlayerStat(models.Model):
player = models.ForeignKey(Player)
rushing_attempts = models.CharField(
max_length = 100,
verbose_name = "Rushing Attempts"
)
rushing_yards = models.CharField(
max_length = 100,
verbose_name = "Rushing Yards"
)
rushing_touchdowns = models.CharField(
max_length = 100,
verbose_name = "Rushing Touchdowns"
)
passing_attempts = models.CharField(
max_length = 100,
verbose_name = "Passing Attempts"
)
谢谢