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 Media class to declare JavaScript and CSS dependencies. Subclasses like ESM render 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’s static() helper.

class django_hstore_widget.widgets.ESM(path)

Bases: Asset

An 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.AdminTextareaWidget

Django 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 Media inner class.

Ejemplo

>>> 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.

Parámetros:
  • name (str) – The HTML name attribute 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.

Devuelve:

The rendered HTML markup for the widget.

Tipo del valor devuelto:

str

class Media
js