python - How to store arbitrary number of fields in django model? -
I am thinking that if there is something in the DJGone that takes care of it.
Usually, I store some XML in the column to do this. Does DJGanga offer some classes which makes it easy, is it XML or some other (better) method?
Thanks, Pete
There are many approaches to solving this problem , And depending on your situation, none of them can work. You can of course use a TextField to store XML or JSON or any other form of text that you can do some expert content with the feature of Python.
You can see the Django Pickle Field Definition on DjangoSnippets:
This allows you to dump the Python dictionaries in the field to manipulate something so that when you refer to those fields You can gain easy access to dictionaries without needing to parse XML or anything else.
I think you can also find out how to write a custom field definition that is similar to other serialization formats, although I'm not sure how useful it can be.
Or to take advantage of many models, you can only make a model again for your model, for a common key, price pair, on your primary model, you have that simple key, value model Will have an M2M reference. In this way you can take advantage of Django ORM for data, context and more.
Comments
Post a Comment