I'm new in django development. I m developing an API in which i am sending data from client side (mobile app) and this data is to be stored in a database using django. And if I query the data the data should be fetched from the DB. Database is preferably postgres/mysql DB. I have written some part of the code but stuck how to proceed. I'll appreciate if someone can guide me how to proceed.
from django.shortcuts import render
from rest_framework.views import APIView
from django.http import Http404
from django.http import JsonResponse
from django.core import serializers
from django.conf import settings
import json
# Create your views here.
@api_view(["POST"])
def getIdealWeight(heightData):
try:
height=json.loads(heightData.body)
weight=str(height*10)
return JsonResponse("the ideal weight is:"+weight+" kg.",safe=False)
except ValueError as e:
return Response(e.args[0],status.HTTP_400_BAD_REQUEST)