Beispiel #1
0
def character_detail(request, pk, format=None):
    try:
        character = Character.objects.get(pk=pk)
    except Character.DoesNotExist:
        return HttpResponse(status=404)

    serializer = CharacterSerializer(character, context={'request': request})
    return Response(serializer.data)
Beispiel #2
0
def character_list(request, format=None):
    characters = Character.objects.all()
    serializer = CharacterSerializer(characters, many=True, context={'request': request})
    return Response(serializer.data)