Working with forms

Overview

Since ModelForm performs an implicit save() on the underlying model when its save() is called, you won’t necessarily have the chance to record the operator and notes on the form instance. For convenience in this situation AuditedModelForm is provided

AuditedModelForm

The only thing that you will need to consider with audited model forms is that save() takes two optional keyword arguments: operator and notes. These work the same as in djangoaudit.models.AuditedModel.set_audit_info().

API Documentation

class djangoaudit.forms.AuditedModelForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)

A version of django.forms.ModelForm to allow operator and notes to be specified to work with djangoaudit.models.AuditedModel

save(commit=True, operator=None, notes=None)

Save the data in the form to the audited model instance.

Parameters:
  • commit (bool) – Whether to commit (see django docs for more info)
  • operator – Optional operator to record against this save
  • notes – Optional notes to record against this save

Table Of Contents

Previous topic

Audited Models

Next topic

The connection to MongoDB

This Page