Django admin proper urls inside listview
Posted
by
hinnye
on Stack Overflow
See other posts from Stack Overflow
or by hinnye
Published on 2011-01-10T21:13:47Z
Indexed on
2011/01/12
3:54 UTC
Read the original article
Hit count: 207
Hi,
My current target is to give users the chance to download CSV files from the admin site of my application.
I successfully managed to create an additional column in the model's list view this way:
def doc_link(self):
return '<a href="files/%s">%s</a>' % (self.output, self.output)
doc_link.allow_tags = True
This shows the file name and creates the link, but sadly - because it's inside my 'searches' view - it has an URL:
my_site/my_app/searches/files/13.csv.
This is my problem, I would like to have my files stored in the admin media directory, like this:
http://my_site/media/files/13.csv
Does somebody know how to give url which points "outer" from the model's directory? Maybe somehow tell Django to use the ADMIN_MEDIA_PREFIX in the link?
I'd really appreciate any help, thanks!
© Stack Overflow or respective owner