How can I get the full/absolute URL (e.g. https://example.com/some/path) in Django without the Sites module? That’s just silly… I shouldn’t need to query my DB to snag the URL!
I want to use it with reverse().
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use handy request.build_absolute_uri() method on request, pass it the relative url and it’ll give you full one.
By default, the absolute URL for
request.get_full_path()is returned, but you can pass it a relative URL as the first argument to convert it to an absolute URL.