Ok, I just decided. I have simplified the code.
Given the following code ...
models.py
from django.db import models from model_utils.managers import InheritanceManager class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80)
api.py
from core.models import Place, Restaurant, Bar
Exit
http://localhost:8000/api/v1/bar/?format=json
{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ { "address": "dawdaw", "custom_field": true, "id": "1", "name": "dwdwad", "resource_uri": "/api/v1/bar/1/" } ] }
Ok
http://localhost:8000/api/v1/restaurant/?format=json
{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ { "address": "nhnhnh", "custom_field": true, "id": "2", "name": "nhnhnh", "resource_uri": "/api/v1/restaurant/2/" } ] }
Ok
http://localhost:8000/api/v1/place/?format=json
{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2 }, "objects": [ { "address": "dawdaw", "id": "1", "name": "dwdwad", "resource_uri": "/api/v1/place/1/" }, { "address": "nhnhnh", "id": "2", "name": "nhnhnh", "resource_uri": "/api/v1/place/2/" } ] }
What i want to achieve
{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2 }, "objects": [ { "address": "dawdaw", "custom_field": true, "id": "1", "name": "dwdwad", "resource_uri": "/api/v1/bar/1/" }, { "address": "nhnhnh", "custom_field": true, "id": "2", "name": "nhnhnh", "resource_uri": "/api/v1/restaurant/2/" } ] }
Decision:
from core.models import Place, Restaurant, Bar