Closed quietlyconfident closed 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:
attachment
attribute is inherited from DownloadMixin
: http://django-downloadview.readthedocs.org/en/1.5/views/custom.html#django_downloadview.views.base.DownloadMixin.attachmentattachment
value is passed to the response class factory: https://github.com/benoitbryon/django-downloadview/blob/1.5/django_downloadview/views/base.py#L113Note: this story looks like #75, where documentation is not obvious about DownloadMixin.basename
and DownloadMixin.get_basename()
usage.
Tagged as "feature". Planned for next release (1.6).
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.