Downloading Django FileField

Lets say you are using Django’s FileField in one of your models. You can put a link to that file in your templates by using the “url” attribute for the field. If the user clicks on the link, the default is for the browser to try to open the file. The user needs to right click to save the file. What if you want saving the file to be the default.

If you are using HTML 5, you can just add the “download” attribute to your <a> tag.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s