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?

Asked By: Brenden

||

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.

Answered By: second

Use the safe filter as a guide on how to write your own that does this.

Answered By: Burhan Khalid
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.