django_hstore_widget.widgets¶
Module Contents¶
- django_hstore_widget.widgets.logger¶
- class django_hstore_widget.widgets.Asset(path)¶
A generic asset reference that resolves to a static file path.
Used by the widget
Mediaclass to declare JavaScript and CSS dependencies. Subclasses likeESMrender the asset as HTML instead of a plain path.- path¶
- absolute_path(path)¶
Return the fully resolved URL for path.
Paths starting with
http://,https://, or/are returned as-is. All other paths are resolved through Django'sstatic()helper.
- class django_hstore_widget.widgets.ESM(path)¶
Bases:
AssetAn ECMAScript module asset.
Renders as a
<script type="module">tag so the browser loads the widget as an ES module.
- class django_hstore_widget.widgets.HStoreFormWidget(attrs=None)¶
Bases:
django.contrib.admin.widgets.AdminTextareaWidgetDjango admin widget that renders the custom hstore editor.
Replaces the default textarea with a Lit-based key-value editor component. Loads the widget JavaScript as an ES module via the
Mediainner class.Example
>>> from django_hstore_widget.widgets import HStoreFormWidget >>> widget = HStoreFormWidget()
- render(name, value, attrs=None, renderer=None)¶
Render the widget HTML for a given form field.
- Tham số:
name (str) -- The HTML
nameattribute for the field.value (dict or None) -- The current hstore data as a key-value mapping.
attrs (dict, optional) -- Additional HTML attributes passed to the template.
renderer (TemplateRenderer, optional) -- Template renderer instance.
- Trả về:
The rendered HTML markup for the widget.
- Kiểu trả về:
str