How To Register hx-requests

There are two ways to register hx_requests.

Using a File

  1. Create an hx_requests.py file in your app.

  2. Add your hx_requests there.

Example directory structure:

my_app/
|── __init__.py
|── models.py
|── views.py
|── hx_requests.py  # This file contains your hx_requests
|── urls.py
|── templates/
|── static/

Using a Directory

  1. Add an hx_requests directory to your installed app.

  2. Add an __init__.py file to the hx_requests directory.

  3. Add a file, which can be named anything, to the hx_requests directory.

  4. Add your hx_requests to the file.

Example directory structure:

my_app/
|── __init__.py
|── models.py
|── views.py
|── hx_requests/
|   |── __init__.py  # Ensures the directory is treated as a package
|   |── my_requests.py  # Contains your hx_requests
|── urls.py
|── templates/
|── static/

Using Nested Subdirectories

You can also organize your hx_requests into nested subdirectories for better organization in larger applications. Each subdirectory must contain an __init__.py file.

Example directory structure:

my_app/
|── __init__.py
|── models.py
|── views.py
|── hx_requests/
|   |── __init__.py
|   |── common.py  # Root-level hx_requests
|   |── users/
|   |   |── __init__.py
|   |   |── profile.py  # User-related hx_requests
|   |   |── settings.py
|   |── products/
|   |   |── __init__.py
|   |   |── crud.py  # Product-related hx_requests
|   |   |── search.py
|── urls.py
|── templates/
|── static/

All .py files in the hx_requests directory and its subdirectories will be automatically discovered and registered.