here i got one endpoint to receive multiple query parameters namely first_name
, last_name
. location
and i need the endpoint to be able to handle following scenarios
- all the 3 param's
- 1 param
- 2 param's
And i found this but still i got 404
when provide one query parameter, only works when all the parameters are given.
urls.py
re_path(r'^project_config/(?P<product>\w+|)/(?P<project_id>\w+|)/(?P<project_name>\w+|)/$',
views.results, name='config')
And view
def results(request, product, project_id, project_name):
response = "You're looking at the results of question %s."
print(product)
print(project_name)
return HttpResponse(response % project_id)
How can allow url to accept optional query parameters ?