django_hstore_field.fields¶
Module Contents¶
- class django_hstore_field.fields.HStoreField(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=NOT_PROVIDED, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=(), error_messages=None, db_comment=None, db_default=NOT_PROVIDED)¶
Bases:
django.contrib.postgres.fields.HStoreFieldDrop-in replacement for Django's
HStoreFieldwith the custom widget.Overrides
formfield()so that the admin and ModelForms automatically useHStoreFormFieldandHStoreFormWidget-- no manual form configuration required.مثال
>>> from django.db import models >>> from django_hstore_field import HStoreField >>> >>> class Product(models.Model): ... name = models.CharField(max_length=100) ... metadata = HStoreField() ... class Meta: ... app_label = "example"
- formfield(**kwargs)¶
Return a form field class pre-configured with the custom widget.
- Parameters:
**kwargs (dict) -- Keyword arguments forwarded to the form field constructor. Pass
form_classorwidgetto override the defaults.- Returns:
A form field instance wired to the hstore widget.
- Return type: