how to get a string input via url which has slash in it?

path('str:input\_string',views.output_string,name="string url")

​

if the string has slash in it , it is treated as a separate path. but i want to treat it as a string even though it has '/' in it.

Posted Mar 16, 2019, 4:04 AM UTC

32
pancakeses•

Can you give an example? Why do you need a slash in it?

Is it two separate things separated by a slash? Will it always be in this format? If so, why not just pull both in as string variables?

path('<str:input_string>/<str:input_string2>',views.output_string,name="string url")

It would help to have more details about what you're actually trying to accomplish.

3
[deleted]•

[deleted]

1
PawelDecowski•

You need to URL-encode slashes because they have special meaning in URLs. Replace slashes with %2F:

http://example.com/some%2Fpath

But it’s a pretty bad idea to use special characters in paths and you should rethink your approach.

2