Skip to main content

Django template tag to load static files inline with your template.

Project description


📖 You find the full documentation on


Works similar to Django’s static templatetag, but this one includes the file directly in the template, rather than a link to it.

You can additionally post-process the file content using custom ‘encoder’.


  1. Put the StaticInlineAppConfig along your apps.

        # ...
  2. Load the template tag and pass a filename as you’d do with a static template tag. You can also post-process the file content. In the example below we encode the content of the mykey.pem file with base64. Several encoders are already built-in, see the Encoder docs.

    {% load staticinline %}
    <style type="text/css">{% staticinline "myfile.css" %}</style>
    My base64 encoded Key: {% staticinline "mykey.pem" encode="base64" cache=True %}
  3. Enjoy the result:

    <style type="text/css">body{ color: red; }</style>
    My base64 encoded Key: LS0tIFN1cGVyIFByaXZhdGUgS2V5IC0tLQo=


v1.3 (2018-08-15)

  • Added cache and cache_timeout templatetag arguments to store rendered values in cache.
  • Added data_response AppConfig method to globally override the template tag response.

v1.2 (2018-08-14)

  • Added support for Django 2.1 and Python 3.7.
  • Added proper documentation.
  • Added sri (Subresource Integrity) encoder to generate a sha256 for a given file.

v1.1 (2018-08-09)

  • Added support for custom data encoders to modify file content on the fly.
  • Added data and base64 encoders, both convert data into base64.

v1.0 (2018-04-29)

  • 🌟 Initial release.

Project details

Download files

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

Files for django-staticinline, version 1.3
Filename, size File type Python version Upload date Hashes
Filename, size django_staticinline-1.3-py2.py3-none-any.whl (23.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-staticinline-1.3.tar.gz (20.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page