【问题标题】:django-nonrel specify MongoDB BSON element name to model attributesdjango-nonrel 指定 MongoDB BSON 元素名称来建模属性
【发布时间】:2012-06-27 23:19:18
【问题描述】:

在 C# 中,可以使用 MongoDB 驱动程序为数据模型中的每个属性定义自定义 BSONElement 名称,以缩短其存储名称,例如

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

有没有办法通过 django-nonrel 设置和定义的模型来实现这一点

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

所以属性“Current”将存储为“c”并在代码中引用为“Current”? 在这方面的研究效果不佳。

【问题讨论】:

    标签: python mongodb django-nonrel bson


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 2019-12-07
      • 2013-11-05
      相关资源
      最近更新 更多