How To Register hx-requests
There are two ways to register hx_requests.
Using a File
Create an
hx_requests.pyfile in your app.Add your
hx_requeststhere.
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
Add an
hx_requestsdirectory to your installed app.Add an
__init__.pyfile to thehx_requestsdirectory.Add a file, which can be named anything, to the
hx_requestsdirectory.Add your
hx_requeststo 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.