开发者

How to embed an ObjectId into a model's field in django nonrel/mongodb-engine?

I'm new to django so I'm a bit lost here but don't see how I can add an ObjectId fie开发者_如何学Cld to a django-nonrel model.

I know joins are bad and I should embed the submodel but in this case (an author) it's not possible and I don't want to use a string to store it (both for performance and portability).

Would a custom field setting the db_type to "objectid"? From what I can gather in the sources it expect objectid field to only be the "pk".

Thanks,


Found a solution, simply using the ForeignKey field works perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜