2๐
What type of file are you working with?
This is used through the HTTP header. If the mime type is a certain type, the browser will decide whether to download or display it. You can also force downloading. The file type will help.
For text files, set the content-type to text/plain
. For JPEGs, set it to image/jpeg
, and for PNGs set it to image/png
. This should overwrite any attachment
values Django is setting.
0๐
You want to use the Content-Disposition header for this. It should any haggling over content-type.
0๐
The default document type is declared under your server settings, not in how you link to the file. If you are under Apache try looking in httpd.conf for
DefaultType text/plain
If it says something different that may be your problem. text/plain
should set all unknowns to download and be viewed in the browser as text.
EDIT:
I donโt know any way of modifying this behavior through javascript as it has to be in the header of the file being downloaded.
- [Answered ]-Display some field from two tables django orm
- [Answered ]-How can I access the elements of a foreign set for a model in Django's get_context_data method?