下面有一个示例类,但是当我运行manage.py syncdb时,下面的索引都没有创建。在互联网上也存在一大堆混乱,我想知道我是否应该使用“Meta”或“MongoMeta”(试过两者)。
允许使用mongodb
在Django-nonrel中自动创建索引的正确方法是什么class Item(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)]
答案 0 :(得分:0)
您必须在django_mongodb_engine
中添加INSTALLED_APPS
才能使其正常运行。