I have django model and a view for it define as:
class ItemViewSet(viewsets.ModelViewSet):
queryset = Item.objects.all()
serializer_class = ItemSerializer
what should i do to return a primary key as response ? This is how my Json looks after making post request:
{
"id": 4,
"UID": "465666700",
"name": "rohit ",
"gender": "MALE",
"yob": "1996"
}
and my response should be: 4 i.e primary key `class ItemSerializer(serializers.ModelSerializer):
class Meta:
model = Item
fields = ('id', 'name', 'mrp','imageid', 'company', 'edible','discount','seller_uid','seller_pk')`
Help Appreciated.
ItemSerializer
code in the question? – Amrullah Zunzunia