Xavier,
My views are pretty simple!
from __future__ import unicode_literals
import django_filters
from rest_framework import viewsets
from .models import Country, State, City
from .serializers import CountrySerializer, StateSerializer, CitySerializer
class CountryViewSet(viewsets.ModelViewSet):
queryset = Country.objects.all()
serializer_class = CountrySerializer
filter_fields = ['name', 'code']
search_fields = ['name', 'code']
ordering_fields = ['name', 'code']
class StateViewSet(viewsets.ModelViewSet):
queryset = State.objects.all()
serializer_class = StateSerializer
filter_fields = ['name', 'code', 'country']
search_fields = ['name', 'code']
ordering_fields = ['name', 'code', 'country']
class CityViewSet(viewsets.ModelViewSet):
queryset = City.objects.all()
serializer_class = CitySerializer
filter_fields = ['name', 'code', 'state']
search_fields = ['name', 'code']
ordering_fields = ['name', 'code', 'state']
On Thu, Feb 2, 2017 at 12:13 PM, Xavier Ordoquy <[email protected]>
wrote:
> This looks more like you’ve set a list for pagination class for that view.
> What does your view looks like ?
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
> Le 2 févr. 2017 à 16:09, Thiago Mambretti <[email protected]> a écrit :
>
> Sorry,
>
> The error I'm getting is the following:
>
>
> Environment:
>
> Request Method: GET
> Request URL: http://192.168.1.208:8000/api/states/
>
> Django Version: 1.10.5
> Python Version: 2.7.6
> Installed Applications:
> ['django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'rest_framework',
> 'crispy_forms',
> 'apps.geodata',
> 'apps.accounts']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback:
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/django/core/handlers/exception.py" in inner
> 39. response = get_response(request)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/django/core/handlers/base.py" in _get_response
> 187. response = self.process_exception_by_middleware(e,
> request)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/django/core/handlers/base.py" in _get_response
> 185. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/django/views/decorators/csrf.py" in wrapped_view
> 58. return view_func(*args, **kwargs)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/viewsets.py" in view
> 83. return self.dispatch(request, *args, **kwargs)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/views.py" in dispatch
> 477. response = self.handle_exception(exc)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/views.py" in handle_exception
> 437. self.raise_uncaught_exception(exc)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/views.py" in dispatch
> 474. response = handler(request, *args, **kwargs)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/mixins.py" in list
> 42. page = self.paginate_queryset(queryset)
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/generics.py" in paginate_queryset
> 170. if self.paginator is None:
>
> File "/home/vagrant/.virtualenvs/prospect/local/lib/python2.7/
> site-packages/rest_framework/generics.py" in paginator
> 163. self._paginator = self.pagination_class()
>
> Exception Type: TypeError at /api/states/
> Exception Value: 'list' object is not callable
>
>
>
>
>
>
>
> On Thursday, February 2, 2017 at 12:07:00 PM UTC-3, Thiago Mambretti wrote:
>>
>> Hi all,
>>
>> Is it possible to use the default pagination backend along with the
>> following filters?
>>
>> 'django_filters.rest_framework.DjangoFilterBackend',
>> 'rest_framework.filters.SearchFilter',
>> 'rest_framework.filters.OrderingFilter',
>>
>>
>> I'm using a ModelViewSet and the API only when I have only the
>> pagination or the filters activated.
>>
>> There's no mention on anything about it on the docs so came here for help.
>>
>> Thanks,
>>
>>
>>
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django REST framework" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-rest-framework/geEBt6SYrkg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Thiago Mambretti
"What you do in life, echoes in eternity."
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.