Form Classes and Mixins

UserSavable

New in version 0.7.

class djem.forms.UserSavable[source]

A mixin for a Django ModelForm that adds support for models using the Auditable model mixin. It handles providing a user instance to the model’s save() method when the form’s own save() method is called, as is required by Auditable.

This mixin assumes the presence of a self.user attribute that the save() method can use. It is designed for use by forms that already accept and store a known user, e.g. as a constructor argument.

For a form that provides the same customisation of the save() method and includes user as a constructor argument, see AuditableForm.

AuditableForm

Changed in version 0.7: Renamed from CommonInfoForm. The old name is still available for backwards compatibility, but is considered deprecated.

class djem.forms.AuditableForm(*args, user=None, **kwargs)[source]

A Django ModelForm that is customised to support models using the Auditable model mixin. It handles providing a user instance to the model’s save() method when the form’s own save() method is called, as is required by Auditable. It also adds a user keyword argument to the constructor so the save() method has a known user to work with. The user argument is required if the field is bound, otherwise it is optional. The given user is stored in the user instance attribute. Subclasses may choose to use the known user for their own purposes.

For a mixin that provides the same customisation of the save() method without the extra constructor argument (e.g. for use by forms that already accept and store a known user), see UserSavable.

user

The user model instance provided to the constructor on instantiation. May be None on unbound forms.