How to download in db zip file in existing view in django?

I want to add download button in existing view.

For example, I have a list board of fruits,

and when I click on them one by one, I move to the detail page,

such as the apple page, the strawberry page, and the grape page.

I want to create a download button for each detail page, and when I press the download button,

I want the user to download the apple.zip, drawberry.zip, and shape.zip files in database.

But I don't know how to do this in a view that's already been created.
My current view is as follows:

class FruitsDetailView(LoginRequiredMixin, DetailView):
    template_name = 'fruits/detail.html'
    login_url = 'login'
    model = Fruits

    def get_context_data(self, **kwargs):
        pk = self.object.pk
        context = super().get_context_data(**kwargs)
        ...

        ...
        context['list'] = json.dumps(trace)
        return context

I'm only exporting the context in this way, can I add a response related to the download here?

In the case of all the articles I looked for, I was creating a separate View exclusively for download.

But that's not the way I want it to be.

I'm a beginner at django, so I don't know where to start.

I'd appreciate if you give me a hint.

Back to Top