Welcome to the django-staticinline Documentation#
π Full documentation: https://django-staticinline.readthedocs.io
π± Github Repository: bartTC/django-staticinline
django-staticinline#
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β.
Compatibility Matrix:#
Py/Dj |
3.8 |
3.9 |
3.10 |
3.11 |
---|---|---|---|---|
2.2 (LTS) |
β |
β |
β |
β |
3.2 (LTS) |
β |
β |
β |
β |
4.0 |
β |
β |
β |
β |
4.1 |
β |
β |
β |
β |
4.2 (LTS) |
β |
β |
β |
β |
Quickstart#
Put the StaticInlineAppConfig along your apps.
INSTALLED_APPS = [ # ... 'staticinline.apps.StaticInlineAppConfig', ]
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 themykey.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 %}
Enjoy the result:
<style type="text/css">body{ color: red; }</style> My base64 encoded Key: LS0tIFN1cGVyIFByaXZhdGUgS2V5IC0tLQo=