Created
November 7, 2016 17:30
-
-
Save akkefa/65cf47090d4cd650cbf4c8ca2667928f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core import serializers | |
from django.http import JsonResponse, HttpResponse | |
def home_page(request): | |
rooms = Room.objects.all().prefetch_related(Prefetch('images', queryset=Image.objects.order_by('-created_at'))) | |
return HttpResponse(serializers.serialize('json', rooms), content_type='application/json') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment