API Reference¶
Admin¶
-
class
eav.admin.
BaseEntityAdmin
(model, admin_site)¶ Base class for entity admin classes.
-
render_change_form
(request, context, **kwargs)¶ Wrapper for ModelAdmin.render_change_form. Replaces standard static AdminForm with an EAV-friendly one. The point is that our form generates fields dynamically and fieldsets must be inferred from a prepared and validated form instance, not just the form class. Django does not seem to provide hooks for this purpose, so we simply wrap the view and substitute some data.
-
-
class
eav.admin.
BaseSchemaAdmin
(model, admin_site)¶ Base class for schema admin classes.
-
class
eav.admin.
BaseEntityInline
(parent_model, admin_site)¶ Inline model admin that works correctly with EAV attributes. You should mix in the standard StackedInline or TabularInline classes in order to define formset representation, e.g.:
class ItemInline(BaseEntityInline, StackedInline): model = Item form = forms.ItemForm
-
formset
¶ alias of
BaseEntityInlineFormSet
-
Fields¶
Forms¶
-
class
eav.forms.
BaseSchemaForm
(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)¶ Base class for schema forms.
-
clean_name
()¶ Avoid name clashes between static and dynamic attributes.
-
-
class
eav.forms.
BaseDynamicEntityForm
(data=None, *args, **kwargs)¶ ModelForm for entity with support for EAV attributes. Form fields are created on the fly depending on Schema defined for given entity instance. If no schema is defined (i.e. the entity instance has not been saved yet), only static fields are used. However, on form validation the schema will be retrieved and EAV fields dynamically added to the form, so when the validation is actually done, all EAV fields are present in it (unless Rubric is not defined).
-
check_eav_allowed
()¶ Returns True if dynamic attributes can be added to this form. If False is returned, only normal fields will be displayed.
-
save
(commit=True)¶ Saves this
form
‘s cleaned_data into model instanceself.instance
and related EAV attributes.Returns
instance
.
-