django_hstore_widget.forms#

Module Contents#

django_hstore_widget.forms.logger#
class django_hstore_widget.forms.HStoreFormField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)#

Bases: django.contrib.postgres.forms.HStoreField

Form field that uses HStoreFormWidget.

Extends Django’s built-in HStoreField to inject the custom widget and override clean() so incoming values are parsed through json.loads.

Example

>>> from django_hstore_widget.forms import HStoreFormField
>>> field = HStoreFormField()
>>> field.widget.__class__.__name__
'HStoreFormWidget'
widget#
clean(value)#

Parse the raw form value into a Python dict.

Parameters:

value (str or dict) – The raw value submitted by the form.

Returns:

The deserialized key-value mapping.

Return type:

dict