3

I have a urlconf with some standard paths and where the paths may optionally have a get paramerter in the form "?format=xlsx".

As I read the DRF documentation, query parameters are ignored by the URLConf resolver.

But , when I add a query parameter like "? format=xlsx to a path that otherwise matches, it no longer matches and I get a "not found" response.

My URLConf is:

urlpatterns = [
    path('', MyListAPIView.as_view(), name="list"),
    path('<sysid>/',MyRetrieveAPIView.as_view(), name="get"),
    path('<sysid>/timeline/',MyTimeLineAPIView.as_view(), name="timeline"),
]

For some reason '22/timeline/' matches but '22/timeline/?format=xlsx' does not.

Why is the query string not being ignored?

1 Answers1

0

when call the '' url and then MyListAPIView view is running, you can access the query_params in this way:

request.query_params

by URL of: /?page=3 we get: enter image description here

Amirio
  • 628
  • 1
  • 6
  • 12