Skip to main content

A ZipFile subclass that accepts Django Templates

Project description

A subclass of zipfile.Zipfile that works with Django templates.

Usage:

from zipfile import ZIP_DEFLATED
from django_zipfile import TemplateZipFile

def myview(request, object_id):
    obj = get_object_or_404(MyModel, pk=object_id)
    context = {
        'object': obj
    }
    response = HttpResponse(mimetype='application/octet-stream')
    response['Content-Disposition'] = 'attachment; filename=myfile.zip'

    container = TemplateZipFile(response, mode='w', compression=ZIP_DEFLATED, template_root='myapp/myzipskeleton/')

    container.add_template('mimetype')
    container.add_template('META-INF/container.xml')
    container.add_template('chapter1.html', context=context)

    container.close()
    return response

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-zipfile-0.0.5.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file django-zipfile-0.0.5.tar.gz.

File metadata

File hashes

Hashes for django-zipfile-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a509c860f300ba946ed0414b5194333f315efd14ce122fa44f3d0697dc755419
MD5 c5d9df118e19fa1455ba17400ac79e39
BLAKE2b-256 4874a5d2b7d8dbfaff0794f8bbd2f1d382c34e98d2fba72de78a861578f03991

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page