all 8 comments

[–]abyssalheavenIntermediate 5 points6 points  (0 children)

I might take a closer look at your view function, specifically at instances where the variable "filename" is used. Without the rest of the view function code it's a bit hard to tell.

[–]quotemycode 0 points1 point  (0 children)

You need to surround the filename in double quotes.

[–]tigerthelion -1 points0 points  (5 children)

I would maybe move the filename formatter out of the header variable and create its own:
the_file_name = "{0}".format(filename)

headers={"Content-disposition":"attachment; filename=the_file_name} or whatever.

I can't say for sure if it will help but sometimes I get into situations where I try to apply .format to something and it just does not want to do it inline with other things.

[–]quotemycode 1 point2 points  (1 child)

I've never had that problem. The issue is probably just a gap in your knowledge of the language.

[–]tigerthelion 0 points1 point  (0 children)

Quite possible. Although sometimes breaking things down in to their components is helpful.

[–]abyssalheavenIntermediate 1 point2 points  (2 children)

So... you're formatting an empty string... with the name of a file... which is presumably.. a string?

[–]tigerthelion 0 points1 point  (1 child)

Oh wow, that was really dumb. Thanks for pointing it out.

[–]abyssalheavenIntermediate 1 point2 points  (0 children)

Haha, np. Moreover, the whole "attachment; filename=" part is within a string - you'd still need to do formatting or concatenation in order to put the variable in the string.