I need a serializer for something like this:
{
\"items\": {
12: {
\"name\": \"item 1\"
},
66: {
\"name\": \"i
Serializer is not needed. You can do simpler with Class-base View:
from rest_framework import views
from rest_framework.response import Response
from django.http import JsonResponse
class ListItems(views.APIView):
def get(self, request, format=None):
items = Item.objects.all().values()
return return JsonResponse(list(items), safe=False)