开发者

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

开发者 https://www.devze.com 2023-02-16 15:37 出处:网络
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'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

精彩评论

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

关注公众号