Skip to main content

This project aims at providing a compromise between dynamic error pages for Django (that use template tags etc and therefore potentially error too) and having to write static error pages by hand.

Project description

Latest Version Travis status Coveralls status Download Wheel Status License

This project aims at providing a compromise between dynamic error pages for Django (that use template tags etc and therefore potentially error too) and having to write static error pages by hand.

It does so by providing a management command that can be invoked to turn a dynamic Django template into a static HTML page with no template tags whatsoever in it.

Note that this means that every time you change your error pages, you need to re-run this script. Ideally this is part of your deploy process.

Installation

pip install django-statictemplate inside your virtualenv.

Add statictemplate to your INSTALLED_APPS.

Configuration

django-statictemplate does not require any configuration. by default.

By default django-statictemplate overrides the configured middlewares for enhanced compatibility and to avoid incompatibilities.

However this may not be always feasible: if you need a specific set of middlewares to be loaded set:

STATICTEMPLATE_OVERRIDE_MIDDLEWARE = False

in you settings files.

Please note that django-statictemplate has not been tested with every possible middleware, thus you may encounter failures and strange behaviors especially fi you use middlewares that changes the response type.

Usage

python manage.py statictemplate dynamic_500.html > 500.html

or

python manage.py statictemplate dynamic_500.html -f 500.html

The management command renders a template given by name (standard Django template name resolution applies) and writes the output to stdout or to a file.

Arguments

  • template: standard django template name to render

  • language: sets the client django_language cookie to render page in the given language

  • extra_request: extra parameters injected in the request. Parameters must be serialized in querystring format (e.g.: 'variable=value&variable=value'; please note the single quote to protect ampersand &).

Options

  • -f, --file: file destionation for command output

License

This project is licensed under the BSD license.

Contributors

See https://github.com/ojii/django-statictemplate/contributors

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-statictemplate-2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

django_statictemplate-2.0-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-statictemplate-2.0.tar.gz.

File metadata

File hashes

Hashes for django-statictemplate-2.0.tar.gz
Algorithm Hash digest
SHA256 f2b1924ba571db7b31e0fd2ab9526f51ff5f1e9a7e723e80aeb423e35b3ebac8
MD5 8b15e3866953b1ce0f822f5392625af7
BLAKE2b-256 db9ba955f52e6ca0f993b350466b21f77bcb79bbdd11e3e19a812f3d98dbb48c

See more details on using hashes here.

File details

Details for the file django_statictemplate-2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_statictemplate-2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 79d3bd724875dae5223de28dabe4e084dac62da1440cf57f77f6c14825c64319
MD5 34794a2a1014845d2052fb0182c7da8a
BLAKE2b-256 9c6e41e51efca943f95e31acb7f891907b47c489e4503fdf7cc2499c9fed12c3

See more details on using hashes here.

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