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.4.tar.gz (2.5 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-zipfile-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9e9bd70be3f5eb1f2fb187a2cc210d35aa51e90bbe9b6b243078e35c2062e07a
MD5 26790456d32c6a9fa3df8676bfdd0973
BLAKE2b-256 6faadc6c2411f85d70212c893070b6c5a99fa8ced3f4010a8417004c6cd1d66f

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