Skip to content
Advertisement

Tag: django-rest-framework

how to return nested json using django rest framework

I am trying build a REST API using django. here is my models.py and serializers.py. models.py serailizers.py Here is my api – http://127.0.0.1:8000/api/city/Sidney/. I am trying to fetch data by city name. I am getting the json in below format. But i want the json in below shown format – i am not getting what change needs to be done

Creating django api view that returns filtered objects

Problem Description I’m new to django-rest-framework and got a problem in my view. I have three models namely #User, #Profession and #StudentProfessions. I need to create an api-view that takes user_id as request-parameter and returns a list of all professions that belongs to a particular user_id. Here’s My Codes profession_app >> models.py User Model I used the django default model.

Advertisement