How to store a dictionary on a Django Model?

前端 未结 13 944
广开言路
广开言路 2020-11-28 23:24

I need to store some data in a Django model. These data are not equal to all instances of the model.

At first I thought about subclassing the model, but I’m trying t

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 00:13

    Being "not equal to all instances of the model" sounds to me like a good match for a "Schema-free database". CouchDB is the poster child for that approach and you might consider that.

    In a project I moved several tables which never played very nice with the Django ORM over to CouchDB and I'm quite happy with that. I use couchdb-python without any of the Django-specific CouchDB modules. A description of the data model can be found here. The movement from five "models" in Django to 3 "models" in Django and one CouchDB "database" actually slightly reduced the total lines of code in my application.

提交回复
热议问题