I want to create a file containing a string and allow the user to download the file when they click a button in the admin detail page. Any ideas?
Probably add html to the form? But how can I do that? I am new to Django.
I want to create a file containing a string and allow the user to download the file when they click a button in the admin detail page. Any ideas?
Probably add html to the form? But how can I do that? I am new to Django.
There are two answer about add download link as new field to details page which is easyer than add download link inside
AdminFileWidget
. I write this answer in case someone need add download link insideAdminFileWidget
. The final result like this:The way to achieve this is:
1
models.py
:2 views.py:
3 urls.py
4 admin.py
5 download_file_input.html
That's all!
In your models.py field for that application, add the following piece of code
Then in your admin.py, add this field to your readonly_fields for that model
You can go along the following lines: