【问题标题】:Will Syncdb use Meta or MongoMeta on Django-nonrel/mongodb Models?Syncdb 会在 Django-nonrel/mongodb 模型上使用 Meta 或 MongoMeta 吗?
【发布时间】:2016-01-20 08:24:52
【问题描述】:

我在下面有一个示例类,但是当我运行 manage.py syncdb 时,没有创建下面的索引。互联网上也有很多混乱,我想知道我应该使用“Meta”还是“MongoMeta”(两者都试过)。

使用 mongodb 在 Django-nonrel 中允许自动创建索引的正确方法是什么

类项目(models.Model): xxx xxx . .

class MongoMeta:    

    unique_together = [("CountryRetailer", "ProductId")]
    indexes =   [
        [('CountryRetailer',1)],
        [('ProductId',1)],
        [('OnlineRetailerName',1)],
        [('UniqueKey', 1)],
        [('Type',1), ('PriceValue',1)],
        [('CreatedOn', -1)]

【问题讨论】:

    标签: mongodb indexing django-nonrel


    【解决方案1】:

    您必须在INSTALLED_APPS 中添加django_mongodb_engine 才能使其工作。

    【讨论】:

      猜你喜欢
      • 2017-04-26
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      • 1970-01-01
      • 2012-07-05
      • 2011-07-06
      • 2014-01-24
      • 1970-01-01
      相关资源
      最近更新 更多