我是django的新人余烬. 你能帮我找到正确的JSOn吗余烬在
我的密码在这里-
在模型.py-在
from django.db import models
class Confusion(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=100)
在序列化程序.py-在
^{pr2}$在视图.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"}}
看看托兰·比卢普斯的ember-data-django-rest-adapter。它应该能满足你的需要。在
看看README-对于基本用途,所有额外的设置都在JavaScript端。在
(我基本上是引用…)
在HTML/构建系统中包含
ember-data.js
之后的ember-data-django-rest-adapter.js
添加自定义适配器:
就这样。(特别是有什么事情你不能工作吗?)在
相关问题 更多 >
编程相关推荐