Assign JSON field to model variable in django -
i having json like:
{ "name": "rahul", "2or4": 2, }
here,
how can assign model variable : twoorfour jason field value "2or4" can not have variable start integer.
i new django. using django-rest-framework api.
if using djangorestframework need override to_representation function in serializer
should this
def to_representation(self, obj) serialized_data = super(serializerclassname, self).to_representation(obj) serialized_data["2or4"] = serialized_data["twoorfour"] //remove old field name del serialized_data["twoorfour"] return serialized_data
this code should work serializerclassname class name of serializer
Comments
Post a Comment