Reputation: 2893
Assume I have a model named MyModel
and I have a Field Named field
Now I want to add three more fields inside the prescription like one field_a
, field_b
and field_c
.
Does Django Allow that in any way or we have to make another model for this purpose and then link with Foreign Key to MyModel?
Upvotes: 0
Views: 40
Reputation: 429
Well I think it is an idea that could lead to some really hard to maintain code and should be well thought through.
That aside If you have a look at: https://docs.wagtail.io/en/stable/topics/streamfield.html It's a special field meant for cms applications that uses json in the field to model dynamic fields and validations for it.
Also if you run postgres this might help. https://docs.djangoproject.com/en/3.2/ref/contrib/postgres/fields/#jsonfield
Upvotes: 1