My Model:
class Post_Data(models.Model):
id = models.AutoField(primary_key=True)
data = models.CharField(max_length=200)
I need to insert the json data inside the model which will be passed in the form of "file" in postman.
I tried:
def post(self, request):
json_file = request.FILES['json_file']
with open(json_file) as f:
json_data = json.loads(f)
a = Post_data(data=json_data)
a.save()
But it's not working.