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.?????
Django documentation says: get_absolute_url() method to tell Django how to calculate the canonical URL for an object.
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.
reverse() If you need to use something similar to the url template tag in your code, Django provides the following function: reverse (viewname, urlconf=None, args=None, kwargs=None, current_app=None)
Just use .url
property of the file field.
See "Managing files" in Django documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With