2👍
✅
The tarfile module is probably a good place to start.
You would probably want to cache the file somewhere in the filesystem to save yourself from too much work. There’s no reason to regenerate the file if the contents haven’t changed.
0👍
You can use django-tarview (install via pip
from PyPi, or get it from github)
Extend tarview.views.BaseTarView
and implement get_files
:
from tarview.views import BaseTarView
class TarView(BaseTarView):
def get_files(self):
return [File(open('test_file.txt'), name="test_file.txt"),
ContentFile(b"I am a text file", name="text.txt")]
- [Answered ]-Django: ForeignKey and instance
- [Answered ]-How to make django to save user password in plain-text?
- [Answered ]-How to save an instance of a Django model to my database
Source:stackexchange.com