当前位置:编程学习 > 网站相关 >>

django models save()

class Types(models.Model):
    title=models.CharField('主题',max_length=20,null =False, blank=False,)
    sortid = models.IntegerField('关联sort',null =True, blank=True)
    class Meta:www.zzzyk.com
        db_table = 'Types' 
        verbose_name = '类型'
        verbose_name_plural = '类型'
        ordering = ['id']
    def save(self, * args, ** kwargs):
        print self.title
        self.title='000000000'
        super(self.__class__, self).save(*args, ** kwargs)
 
自定义保存字段值
补充:Web开发 , Python ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,