Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Django会自动更改驼峰大小写_Python 3.x_Django_Database Migration - Fatal编程技术网

Python 3.x Django会自动更改驼峰大小写

Python 3.x Django会自动更改驼峰大小写,python-3.x,django,database-migration,Python 3.x,Django,Database Migration,我在Django中使用models.IntegerChoices作为枚举,但它以一种改变的方式保存在DB中 class FruitsEnum(models.IntegerChoices): Apple = 1 RedApple = 2 GreenApple = 3 LongBanana = 4 DragonFruit = 5 但它是这样保存在数据库中的:[('0','Apple'),('1','Redapple'),('2','Greenapple')…

我在Django中使用models.IntegerChoices作为枚举,但它以一种改变的方式保存在DB中

class FruitsEnum(models.IntegerChoices):
    Apple = 1
    RedApple = 2
    GreenApple = 3
    LongBanana = 4
    DragonFruit = 5
但它是这样保存在数据库中的:[('0','Apple'),('1','Redapple'),('2','Greenapple')…]

正如你所见,“苹果”这个词在两个单词组合中不是大写的。我怎样才能做到这一点:
[('0','Apple'),('1','RedApple),('2','GreenApple)…]

只传递由整数和相关名称组成的元组,而不是传递整数。比如:

水果类(模型、整数选择):
苹果=1,‘苹果’
红苹果=2,‘红苹果’
绿苹果=3,“绿苹果”
长香蕉=4,‘长香蕉’
龙果=5,‘龙果’
或者,在您的模型中,在使用此选项的
IntegerField
中,您可以用元组替换
foultsenum.choices

[(1,'Apple'),(2,'RedApple'),(3,'GreenApple'),(4,'LongBanana'),(5,'DragonFruit')]
注意:您在这里观察到的任何差异纯粹是表面的,不存在于django之外(即数据库内)。您可以直接打开数据库,看到表中只存储整数