django_htmx_modal_forms package¶
- class django_htmx_modal_forms.HtmxModalCreateView(**kwargs)[source]¶
Bases:
HtmxModalFormMixin,CreateViewView for creating objects via modal forms.
On successful form submission, the page will be refreshed to show the newly created object.
- class django_htmx_modal_forms.HtmxModalFormMixin(**kwargs)[source]¶
Bases:
ViewBase mixin for modal form handling with HTMX and Bootstrap.
This mixin provides the core functionality for handling forms in Bootstrap modals using HTMX for dynamic updates.
- Attributes:
template_name (str): Template for the full modal structure form_template_name (str): Template for just the form content modal_size (str): Bootstrap modal size class (sm, lg, xl) modal_title (str): Custom modal title override
- element_id_prefix: str | None = None¶
- element_id_suffix: str | None = None¶
- form_template_name = 'htmx_modal_forms/_form_content.html'¶
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]¶
Handle GET requests and trigger modal show.
- get_element_id() str[source]¶
Get the element ID for the form target.
This method can be overridden to customize the ID generation. By default, it uses the pattern: “{prefix}{model_name}-{pk}{suffix}”
- get_modal_size() str[source]¶
Get the Bootstrap modal size class.
Override this method to customize the modal size.
- get_modal_title() str[source]¶
Get the title for the modal.
Override this method to customize the modal title.
- modal_size: str = 'lg'¶
- modal_title: str | None = None¶
- template_name = 'htmx_modal_forms/_modal_form.html'¶
- class django_htmx_modal_forms.HtmxModalUpdateView(**kwargs)[source]¶
Bases:
HtmxModalFormMixin,UpdateViewView for updating objects via modal forms.
On successful form submission, the target element will be updated with the new object details.
- Attributes:
detail_template_name (str): Template for rendering updated object details
- detail_template_name: str | None = None¶
Subpackages¶
Submodules¶
django_htmx_modal_forms.apps module¶
django_htmx_modal_forms.conf module¶
These are the available settings.
All attributes prefixed HTMX_MODAL_FORMS_* can be overridden from your Django
project’s settings module by defining a setting with the same name.
django_htmx_modal_forms.main module¶
django_htmx_modal_forms.views module¶
Django HTMX Modal Forms - Class-based views for HTMX-powered Bootstrap modals.
- class django_htmx_modal_forms.views.HtmxModalCreateView(**kwargs)[source]¶
Bases:
HtmxModalFormMixin,CreateViewView for creating objects via modal forms.
On successful form submission, the page will be refreshed to show the newly created object.
- class django_htmx_modal_forms.views.HtmxModalFormMixin(**kwargs)[source]¶
Bases:
ViewBase mixin for modal form handling with HTMX and Bootstrap.
This mixin provides the core functionality for handling forms in Bootstrap modals using HTMX for dynamic updates.
- Attributes:
template_name (str): Template for the full modal structure form_template_name (str): Template for just the form content modal_size (str): Bootstrap modal size class (sm, lg, xl) modal_title (str): Custom modal title override
- element_id_prefix: str | None = None¶
- element_id_suffix: str | None = None¶
- form_template_name = 'htmx_modal_forms/_form_content.html'¶
- get(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]¶
Handle GET requests and trigger modal show.
- get_element_id() str[source]¶
Get the element ID for the form target.
This method can be overridden to customize the ID generation. By default, it uses the pattern: “{prefix}{model_name}-{pk}{suffix}”
- get_modal_size() str[source]¶
Get the Bootstrap modal size class.
Override this method to customize the modal size.
- get_modal_title() str[source]¶
Get the title for the modal.
Override this method to customize the modal title.
- modal_size: str = 'lg'¶
- modal_title: str | None = None¶
- template_name = 'htmx_modal_forms/_modal_form.html'¶
- class django_htmx_modal_forms.views.HtmxModalUpdateView(**kwargs)[source]¶
Bases:
HtmxModalFormMixin,UpdateViewView for updating objects via modal forms.
On successful form submission, the target element will be updated with the new object details.
- Attributes:
detail_template_name (str): Template for rendering updated object details
- detail_template_name: str | None = None¶