Django change url from http:// to http://
Question:
I’m getting a response from an API that formats URLs like: http://domain.com/
. How do I make them normal URLs?
Answers:
Simply do:
url.replace('/', '/')
There isn’t anything built-in, but leaving it as an exercise for you to turn this into a custom template filter. The docs are pretty good.
Use the safe filter as a guide on how to write your own that does this.
I’m getting a response from an API that formats URLs like: http://domain.com/
. How do I make them normal URLs?
Simply do:
url.replace('/', '/')
There isn’t anything built-in, but leaving it as an exercise for you to turn this into a custom template filter. The docs are pretty good.
Use the safe filter as a guide on how to write your own that does this.