How to withdraw different querisets in Django Rest framework?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
Maybe a little bit wrong question formulated. In General, do not understand how to bring using DRF various collections of objects. Trying to understand by analogy with django views. I have to get a list of all locations, a list of the most popular and a list of editor's choice.

def places_list(request): places = Places.objects.all() editor_places = Places.objects.filter(editor_choice = True ) popular_places = Places.objects.filter(most_popular = True ) return render (request, "places/places_list.html", {"places": places, "editor_places": editor_places, "popular_places": popular_places, })

And then have the template display for example 3 tables with the parameters I need.

Make API


class PlaeceSerializer(serializers.ModelSerializer): class Meta: model = Places fields = ( 'main_photo', 'name', )


class PlacesListAPIView(ListAPIView): queryset = Places.objects.all() serializer_class = PlaeceSerializer

So I have formed a collection of json containing all the objects. How to sample in or as that work at the front with the received data? Share your experience, please. Preferably with explanation of process )
by | 24 views

1 Answer

0 like 0 dislike

see for yourself how much data you have
if a little, all in a single json and renders via push the link above
if a lot,

and the front let pulls this url with parameters

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
40,796 users