我是 django 和 ember.js 的新手。你能帮我看看如何为 ember.js 找到正确的 JSOn
我的代码在这里 -
在models.py -
from django.db import models
class Confusion(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=100)
在 serializers.py -
from rest_framework import serializers
from confusion.models import Confusion
class ConfusionSerializer(serializers.ModelSerializer):
class Meta:
model = Confusion
fields = ('id', 'title', 'description')
在views.py -
from rest_framework import generics
from confusion.models import Confusion
from confusion.serializers import ConfusionSerializer
class ConfusionList(generics.ListCreateAPIView):
queryset = Confusion.objects.all()
serializer_class = ConfusionSerializer
class ConfusionDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Confusion.objects.all()
serializer_class = ConfusionSerializer
现在我得到像 -
[{"id": 1, "title": "Career", "description": "I am confused about my career"}]
但是我需要:
{"confusion":{"id": 1, "title": "Career", "description": "I am confused about my career"}}