Views.py
class CountryViewSet(viewsets.ViewSet):
serializer_class = CountrySerializer
pagination_class = LimitOffsetPagination
def list(self,request):
try:
country_data = Country.objects.all()
country_serializer = CountrySerializer(country_data,many=True)
return Response(
data = country_serializer.data,
content_type='application/json',
)
except Exception as ex:
return Response(
data={'error': str(ex)},
content_type='application/json',
status=status.HTTP_400_BAD_REQUEST
)
Settings.py i have added
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
in my urls.py
router = routers.DefaultRouter(trailing_slash=False)
router.register(r'country', CountryViewSet, base_name='country')
urlpatterns = [
url(r'^', include(router.urls)),
]
When I try with this URL http://192.168.2.66:8001/v1/voucher/country it is returning all data.
But when I am trying with this URL http://192.168.2.66:8001/v1/voucher/country/?limit=2&offset=2
but it is returning 404 error. I am new to django.kindly help me :)