,'myproject.myapp.views.myview'), How can I change this so that "the_p...">

How to write this url in Django?

(r'^/(?P<the_param>[a-zA-z0-9_-]+)/$','myproject.myapp.views.myview'),

How can I change this so that "the_param" accepts the URL (encoded) as a parameter?

So, I want to pass the URL to it.

mydomain.com/http%3A//google.com

Edit: Should I remove the regex like this ... and then it will work?

(g '^ / (? P [*]?) /? $', 'Myproject.myapp.views.myview'),

+3
source share
3 answers

Add %and .in the character class:

[a-zA-Z0-9_%.-]

. , . -, , ( python 2.4.x, 2.5.x, 2.6.x) (python 2.7.x), - [a-zA-Z0-9_%-.] .

+2

- :

(r'^the/uri/is/(?P<uri_encoded>[a-zA-Z0-9~%\._-])$', 'project.app.view'),

.

, mydomain.com/http%3A%2F%2Fgoogle.com ( ).

0

,

(r'^(?P<url>[\w\.~_-]+)$', 'project.app.view')
0

Source: https://habr.com/ru/post/1740065/


All Articles