Blog API with Django Rest Framework 12 of 33 – Filtering a Queryset in a ListAPIView



Blog API with Django Rest Framework 12 of 33 – Filtering a Queryset in a ListAPIView

** Blog API with Django Rest Framework ** is a project to build a RESTful API service for the blog we created in Advancing the Blog and Try Django 1.9.

RESTful API services allow our applications to connect with other applications using JSON-formatted data. An strong API can enhance our applications ability to provide value to other services and end users. This type of API is very common in modern web…

9 Comments

  1. hi. i try return queryset object from get_queryser method ` def get_queryset(self):
    return User.objects.get(
    id=self.request.user.id
    )` but he is call error 'User' object is not iterable All problem is FILTER and GET i don't wanna return array with objects i wanna take only 1 object how i can do that? ty for the response

  2. TypeError at /api/posts/
    'type' object is not iterable

    Help Please?

    Edit:
    Got the error. didn't put [] on search_fields.
    it should've been like this, filter_backends = [SearchFilter, OrderingFilter]

  3. I have a variable, j= sheet[col10].value and try to pass it as address1 = ADDRESS.objects.get(Store_Nbr = j)

    but this is showing an error "ADDRESS matching query does not exist." while both field are having the same value 3699. how i can achieve this

  4. When I add the SearchFilter query and I use "?search=new post" I start getting this TypeError:
    Related Field got invalid lookup: icontains
    I'm confused because icontains belongs to the Q query

    edit:
    figured it out. search_fields needed to search for "user__username" not just "user"

Leave a Reply

Your email address will not be published.


*