Skip to main content


📖 Full documentation: https://barttc.github.io/django-staticinline/
🐱 GitHub Repository: https://github.com/bartTC/django-staticinline

django-staticinline

Works similar to Django's static template tag, 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.9 3.10 3.11 3.12 3.13
4.2 (LTS)
5.0
5.1

Quickstart

  1. Put the StaticInlineAppConfig along your apps.

    INSTALLED_APPS = [
        # ...
        'staticinline.apps.StaticInlineAppConfig',
    ]
    
  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>{% staticinline "myfile.css" %}</style>
    My base64 encoded Key: {% staticinline "mykey.pem" encode="base64" cache=True %}
    
  3. Enjoy the result:

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

Changelog

v1.6 (2024-11-19)

  • Python 3.13 compatibility and tests.
  • Drop support for Django <= 4.1.
  • Drop support for Python 3.8.

v1.5 (2024-08-11)

  • Django 5.0, 5.1 compatibility and tests.
  • Python 3.12 compatibility and tests.
  • Type annotations.
  • Switch from pipenv to Poetry.

v1.4 (2023-04-29)

  • Django 3.2 to 4.2 compatibility and tests.
  • Python 3.8 to 3.11 compatibility and tests.

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.

Release files for django-staticinline 1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-staticinline 1.6
File Size Uploaded
django_staticinline-1.6.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-staticinline 1.6
File Interpreter ABI Platform
django_staticinline-1.6-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / django_staticinline-1.6.tar.gz

Download URL django_staticinline-1.6.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
14c3478b546e37931d497209e67d35033acb49bac387b0688148c61d4ee40947
BLAKE2b-256 checksum
How to use checksums
f71ec1180e76aa5fd14a34a6cbe076718698e9269d213adc0de189a847f7ed9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Darwin/24.1.0

Release files / django_staticinline-1.6-py3-none-any.whl

Download URL django_staticinline-1.6-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dab047a89093554f139e0c2139eb469f07172cf5d7551c6967378c757b120584
BLAKE2b-256 checksum
How to use checksums
6743596f128f3d61ed6d1b945fbcab4f7fc93a18e928bc587a93b57c657a58d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Darwin/24.1.0

Release history Release notifications | RSS feed

This release

1.6 This release

2 release files

1.5

2 release files

1.4

2 release files

1.3.1

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page