Configuration

Djxi exposes several package settings that you can override in your project’s settings.py. Reasonable defaults are provided.

Key settings (defaults shown):

  • DX_HTMX_VERSION = “4” (choose between ‘2’ and ‘4’)

  • DX_HTMX_COMPRESSION = “.js” (or “.min.js”)

  • DX_SECTION_TAG = “dx-section”

  • DX_INCLUDE_TAG = “dx-include”

  • DX_MESSAGE_CONTAINER_ID = “message-container”

  • DX_MESSAGE_SWAP_METHOD = “beforeend”

  • DX_MESSAGE_TEMPLATE = “djxi/messages/message_list.html”

Example configuration in settings.py:

DX_HTMX_VERSION = '4'
DX_HTMX_COMPRESSION = '.min.js'
DX_SECTION_TAG = 'dx-section'
DX_INCLUDE_TAG = 'dx-include'

The djxi.conf.Settings proxy (importable as djxi.conf.package_settings) will return these values from django.conf.settings if present, otherwise it will use the defaults defined by djxi.

Templatetags

  • {% htmx_script_inclusion %}: includes the configured htmx CDN script and integrity attribute.

  • {% htmx_headers %}: sets block attributes for explicit inheritance when needed.

  • {% flash_messages_inclusion %}: renders the message container context for the message OOB swaps.

To use the templatetags, load them in your base template and place them where appropriate (for example include htmx_script_inclusion in the <head>).

Example base template snippet:

{% load djxi %}
<!doctype html>
<html>
  <head>
    {% htmx_script_inclusion %}
  </head>
  <body {% htmx_headers %}>
    {% flash_messages_inclusion %}
    ...
  </body>
</html>