tags:

views:

518

answers:

2

Exactly the same as this question, but there must be a way to do it 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().

+2  A: 

Examine Request.META dictionary that comes in. I think it has server name and server port.

Kugel
+5  A: 

Use handy build_absolute_uri() method on request, pass it the relative url and it'll give you full one.

Dmitry Shevchenko
Looks like it should work... I'll try it tomorrow, thanks :D
Mark
+1 This function uses the same data that are in my answer. And is definitely a more convenient option.
Kugel
Took me awhile to get back to this, but yep, works beautifully! Thank you. Just a note to others: it's `request.build_absolute_uri()`. I was looking for what I import I needed, but you just need to use the request object your view already receives.
Mark