Django, get_absolute_url method for file object

Ghostino Doggio picture Ghostino Doggio · Apr 17, 2012 · Viewed 22k times · Source
def get_absolute_url(self):
        return "/uploads/%i" % self.id

It's not what I want but This is far as I can think of. I need a link for my files (like.../photo.jpg)

I just learned how to get feeds from my django website. And I want this jpeg's absolute url.

http://myDjangoWeb/uploads/goodies_89087_1211864024_1.jpeg

How can I get this file's absolute url.....self.?????

Answer

vartec picture vartec · Apr 17, 2012

Just use .url property of the file field.

See "Managing files" in Django documentation.