Skip to content

Commit 136cbe8

Browse files
committed
Query is not a Tag, meaning the HTML it produces on the top level can be configured and is no longer hard coded to a div with a specific id
1 parent cb2dea2 commit 136cbe8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

iommi/query.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
evaluate_strict,
5858
)
5959
from iommi.form import Form, bool_parse, boolean_tristate__parse, date_parse, float_parse, int_parse, time_parse
60+
from iommi.attrs import Attrs
6061
from iommi.fragment import (
6162
Fragment,
63+
Tag,
6264
)
6365
from iommi.from_model import (
6466
AutoConfig,
@@ -641,7 +643,7 @@ def on_bind(self) -> None:
641643

642644

643645
@declarative(Filter, '_filters_dict', add_init_kwargs=False)
644-
class Query(Part):
646+
class Query(Part, Tag):
645647
# language=rst
646648
"""
647649
Declare a query language. Example:
@@ -658,6 +660,8 @@ class AlbumQuery(Query):
658660
"""
659661

660662
auto: QueryAutoConfig = Refinable()
663+
attrs: Attrs = SpecialEvaluatedRefinable()
664+
tag: str = EvaluatedRefinable()
661665
form: Namespace = Refinable()
662666
advanced: Namespace = Refinable()
663667
model: Type[Model] = SpecialEvaluatedRefinable()
@@ -678,6 +682,8 @@ class Meta:
678682
auto = EMPTY
679683

680684
@with_defaults(
685+
tag='div',
686+
attrs__id=lambda query, **_: 'iommi_' + query.iommi_dunder_path,
681687
endpoints__errors__func=default_endpoint__errors,
682688
form__attrs={'data-iommi-errors': lambda query, **_: query.endpoints.errors.iommi_path},
683689
form_container__call_target=Fragment,

iommi/templates/iommi/query/form.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% load i18n %}
2-
<div id="iommi_{{ query.iommi_dunder_path }}">
2+
{{ query.iommi_open_tag }}
33
{{ query.form.iommi_open_tag }}
44

55
{% if query.advanced %}
@@ -20,4 +20,4 @@
2020

2121
{{ query.form.render_actions }}
2222
{{ query.form.iommi_close_tag }}
23-
</div>
23+
{{ query.iommi_close_tag }}

0 commit comments

Comments
 (0)