Installation and Setup

Requirements

  • Python 3.8+

  • Django 3.2+ (the example uses features available in Django 4.x)

Installation

Install djxi in your project using pip (replace with your preferred method):

$ pip install djxi

Add it to your INSTALLED_APPS if you want to use the bundled templates or template tags (htmx script inclusion and message container):

INSTALLED_APPS = [
    # ...
    'djxi',
]

Static assets and templates are expected to be available via standard Django APP_DIRS=True template discovery.

Enable the middleware to access request.htmx … HX-Headers and set Response-Headers via response.htmx … For detailed usage see middleware section.

MIDDLEWARE = [
    ...
    "djxi.middleware.DjxiHeadersMiddleware",
    ...
]

Running the included example

An example Django project is included in sourcecode/example. To run it, create a virtualenv, install Django and the project’s requirements, then run migrations and start the development server:

cd sourcecode/example
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

Open http://127.0.0.1:8000/ to explore the sample showcases and todo app.

Notes

  • The example uses Django’s messaging framework and sample templates bundled in the example app; explore sourcecode/example/todo/views.py to see a full-featured DXEndpointBattery example.