0

Can't match regex for django url you need to process an incoming request from the frontend

 "GET /api/city_list/9/?q=test HTTP/1.0" 404 Not Found

 "GET /api/city_list/9/?q=tt HTTP/1.0" 404 Not Found

I tried several options

path('api/city_list/<int:id>/?q=<str:q>', api_city_list, name='api_city_list'),

does not work

re_path(r'^api/city_list/\d+/\?|&q=\w', api_city_list, name='api_city_list'),

does not work

re_path(r'^api/city_list/<int:id>/(?P<q>\D+)', api_city_list, name='api_city_list'),

does not work

Friends, tell me how to do it, otherwise I'm already confused with regular expressions for Django

(Django 3.1)

  • Query string parameters (`?q=...`) are **not** part of the URL. You should manually process them in your view, using the `request.GET` dictionary. – Selcuk Aug 15 '21 at 23:53

0 Answers0