You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When applications want to indicate to users whether they have seen/downloaded a document or not, this would probably happen with the help of a boolean has_been_downloaded model field on the corresponding model.
To actually turn this field true once a document has been downloaded, it would be really helpful if the package could send a signal, offer a hook, that gets triggered, when a document was shipped successfully.
I guess this could be implemented with some custom code in a custom view that wraps one of the package views.
DRF example:
@action(detail=True)defdownload(self, request, pk):
document=self.get_object()
# When the owner downloads the document, we want to update the# has_been_downloaded field correspondinglyifdocument.has_been_downloadedisFalse:
document.has_been_downloaded=Truedocument.save()
returnObjectDownloadView.as_view(
model=Document,
)(request, pk=pk)
But this would always happen before the actual download code runs and therefore, when the download somehow fails, data would wrongly be changed in the model.
The text was updated successfully, but these errors were encountered:
devidw
changed the title
Signal event once file has been downloaded?
Signal/event once file has been downloaded?
Sep 8, 2022
When the whole download process is handled by django you can use the request-finished.
However if the download is handled by the reverse proxy (Apache or Nginx or other) there is no way to handle it in django since the process is not handled by the application server.
When applications want to indicate to users whether they have seen/downloaded a document or not, this would probably happen with the help of a boolean
has_been_downloaded
model field on the corresponding model.To actually turn this field true once a document has been downloaded, it would be really helpful if the package could send a signal, offer a hook, that gets triggered, when a document was shipped successfully.
I guess this could be implemented with some custom code in a custom view that wraps one of the package views.
DRF example:
But this would always happen before the actual download code runs and therefore, when the download somehow fails, data would wrongly be changed in the model.
The text was updated successfully, but these errors were encountered: