My class looks like this:
class Foo(models.Model):
known_by = JSONField()
My data looks like this
{ "known_by" : [
{'by':'name1', 'value':['def']},
{'by':'name2', 'value':['bar']}
]
}
Is there any way for me to enforce that the Jsonfield
needs to follow the format of by,value[]
dict. I know how to do this using serialiazers
Any other cleaner way to enforce this(in the model definition itself)? Thanks