简体   繁体   English

django-nonrel为模型属性指定MongoDB BSON元素名称

[英]django-nonrel specify MongoDB BSON element name to model attributes

In C# it is possible to use the MongoDB driver to define a custom BSONElement Name to each attribute in your data models, in order to shorten its stored name, such as 在C#中,可以使用MongoDB驱动程序为数据模型中的每个属性定义一个自定义BSONElement名称,以缩短其存储的名称,例如

[BsonElement("c")]
public Boolean Current { get; set; }

Is there any way to accomplish this with a django-nonrel setup and a model defined like 有什么办法可以通过django-nonrel设置和定义的模型来完成此操作

class Test(models.Model):
    Current = models.BooleanField()

so that the attribute "Current" will be stored as "c" and be referenced in code as "Current"? 以便将属性“当前”存储为“ c”,并在代码中将其引用为“当前”? Research did not work very well on this one. 在这一方面的研究效果不佳。

尝试将db_column选项设置为BooleanField或任何字段-应该是存储在MongoDB中的实际字段名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM