I am creating an application that uses Ember and Django. For the backend of Django do I use rest_framework with the ModelViewSet as my view class. In the frontend with Ember do I use the RESTAdapter.
My backend sends data back like this:
{
"id": 22,
"name": "test",
"startdate": "2019-01-01",
"enddate": "2018-12-26"
}
while my frontend expects it like this:
{
"appointment": {
"id": 1,
"name": "test",
"startdate": "2019-01-01",
"enddate": "2018-12-26"
}
}
I can't figure out how to make either end conform the other end in a nice and clean way. In the Django view class could I do this:
def list(self, request):
"""Send all appointments."""
serializer = AppointmentSerializer(self.queryset, many=True)
return Response({'appointment': serializer.data})
and it would work to get the appointments, but then I would have to alter all the functions like create, update, delete etc. I feel like there has to be a clean and better maintainable way to fix this issue.
Aucun commentaire:
Enregistrer un commentaire