十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本文实例为大家分享了Django实现表单验证的具体代码,供大家参考,具体内容如下
models.py
class Users(models.Model): nickname = models.CharField(max_length=16, null=False, blank=False, unique=True) email = models.EmailField(max_length=32, null=False, blank=False, unique=True) password = models.CharField(max_length=64, null=False, blank=False) head = models.ImageField(default="decault.png") age = models.CharField(max_length=3,blank=True,null=True) sex = models.CharField(max_length=2, blank=True, null=True) isactivate = models.BooleanField(default=False) def save(self): if not self.password.startswith('pbkdf2_'): self.password = make_password(self.password) super().save()