jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
380 stars 58 forks source link

Documentation / ObjectDownloadView without attachment? #80

Closed quietlyconfident closed 10 years ago

quietlyconfident commented 10 years ago

I'd like to create a view which is just like ObjectDownloadView, but returns the response NOT as an attachment. I've been reading the documentation trying to figure out how to do this, and I see how I could do it by copying a lot of code and changing one flag, but it seems that the point of the Make Your Own View section is that it should be possible to do so in a more DRY manner. Maybe the documentation says how to do this but if so, I don't understand it.

Is it possible to change the settings on the DownloadMixin by passing arguments to ObjectDownloadView? Or otherwise possible to create a new view which inherits everything from ObjectDownloadView but changes the attachment value? If someone could explain it to me, I'd be happy to format up the response and propose it for the documentation.

benoitbryon commented 10 years ago

I'd like to create a view which is just like ObjectDownloadView, but returns the response NOT as an attachment. [...] Is it possible to change the settings on the DownloadMixin by passing arguments to ObjectDownloadView? Or otherwise possible to create a new view which inherits everything from ObjectDownloadView but changes the attachment value?

You should be able to set attachment = False either via ObjectDownloadView.as_view():

ObjectDownloadView.as_view(model=Document, attachment=False)

Or in ObjectDownloadView subclass:

class MySpecialObjectDownloadView(ObjectDownloadView):
    attachment = False

If the solutions above do not work, then it is a bug.

I'd be happy to format up the response and propose it for the documentation.

Agreed!

Additional notes about internals:

benoitbryon commented 10 years ago

Note: this story looks like #75, where documentation is not obvious about DownloadMixin.basename and DownloadMixin.get_basename() usage.

benoitbryon commented 10 years ago

Tagged as "feature". Planned for next release (1.6).