M
M
Maxim Stikharev2018-05-15 09:14:41
Django
Maxim Stikharev, 2018-05-15 09:14:41

How to write correct regular expression for url?

URL:

url(r'^posts/(?P<account>\w+)/$', views.show_post, name='posts')

When switching, let's say to an account test, everything works fine, but if the account is, let's say, test.testor test2testgives a 404 error, I understand that this is the case \w+. The question is, how can any argument, be it a number, a character or a letter, be passed through a variable to the view?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question