Per instance dynamic fields django model -


I have a link to a JSON field or CouchDB document. I can currently use dynamic information like: < Instead of genericdocument.sample_subfield / p>

genericdocument.objects.get (pk = 1) == genericdocument.json_field ['sample subfield'] / P>

currently maintaining compatibility with all projects .

** UPDATE ** This is very close to what I am trying to achieve: but instead using the Django standard field.

This helps:

  class genericDocument (models.model ): ... @property def sample_subfield (auto): Return self.json_field ['sample_subfield']  

Known for "sample_subfields" should work well if not too high.

If you want to be able to call genericdocument.XXX (where XXX is anything ), you will get the __ getattribute __ < / Overwrite on the code> in my model which I will not actually put into consideration because Django does the job


Comments