I have the following setup:
I want to list all holidays of a specific year. That's why I leave out the default list view and implement my own like this:
class HolidayViewSet(mixins.RetrieveModelMixin, GenericViewSet):
@list_route()
def year(self, request, year=get_today().year):
public_holidays = self.get_queryset().filter(date__year=year)
page = self.paginate_queryset(public_holidays)
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(public_holidays, many=True)
return Response(serializer.data)
If I use the default /holiday/year/ I get a result for the current year.
But whe I try to pass a parameter, I'll get a 404. The 404 page (in debug mode) even shows me the correct URL pattern:
api/v1/ ^holiday/year/$ [name='holiday-year']
api/v1/ ^holiday/year\.(?P<format>[a-z0-9]+)/?$ [name='holiday-year']
In the documentation this aspect is unfortunately not covered.
Any ideas why my route to holiday/year/2017 is not working?