标签:操作 init col turn field super nec orm pre
class MyCharField(models.Field): """ 自定义的char类型的字段类 """ def __init__(self, max_length, *args, **kwargs): self.max_length = max_length super(MyCharField, self).__init__(max_length=max_length, *args, **kwargs) def db_type(self, connection): """ 限定生成数据库表的字段类型为char,长度为max_length指定的值 """ return ‘char(%s)‘ % self.max_length
标签:操作 init col turn field super nec orm pre
原文地址:https://www.cnblogs.com/YiDuoHua/p/10678449.html