1π
It looks like it is a problem with your regex for the url.
What you have
(?P<city>[-\w])
will match only 1 digit, word character, whitespace, underscore, or hyphen. What you should have is
(?P<city>[-\w]+)
which will match 1 or more like you do with the rest of them.
The other thing is that you can try is changing
url = reverse('display_filter', args=(), kwargs={'continent':param1,'country':param2,'city':param3,'street':param4})
return redirect(url)
to
return redirect('display_filter', continent=param1, country=param2, city=param3, street=param4)
redirect
is meant to be a shortcut so you donβt have to call reverse
since it does that for you.
0π
I think you need to do two things:
-
Add a URL to your urls.py that matches with your 3 params case:
url(r'^display_filter/(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$', 'examples.views.display_filter', name='display_filter'),
-
You must set a default value for the fourth param in your view method:
def display_filter(request, continent, country, city, street=None):
Then, you can call the URL just with three params.
- [Answer]-How to store variable length list of dict-type objects with FKs in Django SQL DB
- [Answer]-Django crispy forms β VariableDoesNotExist
- [Answer]-Alphabetically order values in a Many-to-Many relation, then list_display the first item
- [Answer]-Python xml processing β how to loop through all elements?
- [Answer]-Django's Inline Admin's Delete checkbox always returns true