URL pattern for URL with query string

84 views
Skip to first unread message

S D

unread,
Jan 13, 2020, 9:17:13 AM1/13/20
to django...@googlegroups.com
Hey guys. SOS please. How do I write a URL pattern for a URL like this? 

weather/?current_location=-33.927407,18.415747&booking_location=-32.927407,19.415747

When I do reverse(‘weather’, kwargs={‘current_location’: some_value, 'booking_ location’: another_value}) I am getting a NoReverseMatch exception.


Kind regards,
- SD

Jason

unread,
Jan 13, 2020, 9:28:30 AM1/13/20
to Django users
The url resolver does not include GET query params in a URL, you need to add them manually after the string.

for example

    url = f"{reverse('weather')}/?current_location={some_value}&booking_location={another_value}"

S D

unread,
Jan 13, 2020, 10:01:58 AM1/13/20
to django...@googlegroups.com
Thanks Jason.



Kind regards,
- SD

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6dd43044-909b-49b2-87fc-5344508af9e8%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages