加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

如何从django模型创建双重和长文本字段

发布时间:2020-12-20 11:45:13 所属栏目:Python 来源:网络整理
导读:如何使用 django模型在 mysql中创建一个双字段.我遇到这个错误,以及如何使用django创建一个longtext数据类型 class Test(models.Model): maxcount = models.DoubleField(null=True) ## double DEFAULT NULL,cs = models.TextField()#longtext, 错误: maxcou
如何使用 django模型在 mysql中创建一个双字段.我遇到这个错误,以及如何使用django创建一个longtext数据类型

class Test(models.Model):
   maxcount = models.DoubleField(null=True) ## double DEFAULT NULL,cs = models.TextField()#longtext,

错误:

maxcount = models.DoubleField(null=True) ##double DEFAULT NULL,AttributeError: 'module' object has no attribute 'DoubleField'

解决方法

https://docs.djangoproject.com/en/1.8/ref/models/fields/#bigintegerfield
https://docs.djangoproject.com/en/1.8/ref/models/fields/#decimalfield
https://docs.djangoproject.com/en/dev/ref/models/fields/#floatfield

如果需要Integer和decimal字段,请使用big int.
将https://docs.djangoproject.com/en/1.8/ref/models/fields/#charfield用于Char字段并设置max和min参数

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读