python - django admin export to csv downloadable link -


looking @ https://docs.djangoproject.com/en/1.8/howto/outputting-csv/

in admin.py, i've added method generate csv list of row in table (and works), i'm missing downloadable link csv file.

def prova(self, obj):     """ export csv """      # create httpresponse object appropriate csv header.     dwfilename = obj             response = httpresponse(content_type='text/csv')     response['content-disposition'] = 'attachment; filename=%s"%dwfilename'      writer = csv.writer(response, delimiter=';',)      models import righe     = righe.objects.filter(progressivo=obj)      x in a:                writer.writerow([x.field1, x.field2, x.field3])      # ugly parts won't work     link="<a href='response'>download csv file</a>"              return link  prova.allow_tags = true         

documentation says should appear "save in browser", plain text in cell:

content-type: text/csv content-disposition: attachment; filename=%s"%dwfilename 000xxxx.... 


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -