I am passing 2 variables in the URL foo, bar. The variable bar has a multiple words with spaces between it. On the basis of foo and bar the content of the template is rendered. Whenever bar has a space in between the words my url handler gives a 404.
example: localhost/post/foo/ba r/ results in a 404
urls.py
urlpatterns = [
re_path('post/<slug:foo>/<slug:bar>/', post),
]
views.py
def post(request, foo, bar):
query = Blog.objects.all().filter(category=foo, title=bar)
return render(request, 'blog/post.html',
{'blog': query, 'cat': foo, 'tit': bar})
post.html
{% for i in blog %}
{{ i.content }}
{% endfor %}
fooandbarbeforequery?print(foo) print(bar)and check whats the output in console [assuming you're using python3]barwill contain multiple words and spaces in between them