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.2cto.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)
 
自定义保存字段值

相关内容

    暂无相关文章

评论关闭