Actions define what happens once a user submits a FormModelForm. django-dynamic-forms provides two basic actions dynamic_form_send_email() and dynamic_form_store_database() that, as their names indicate, either send the submitted data via e-mail to the receipients defined in the DYNAMIC_FORMS_EMAIL_RECIPIENTS settings variable or stores it into the database (precisely the FormModelData model).

Any action that should be available for usage must be registered in the ActionRegistry. This can be done with the following code:

>>> def my_function(form_model, form):
...     # do something
...     pass
>>> from dynamic_forms.actions import action_registry
>>> action_registry.register(my_function, 'My Label')

This allows one to register an action during runtime. But many actions are already available during compile or start-up time and can be registered then by using a handy decorator formmodel_action(). Given the above situation, this would look like:

>>> from dynamic_forms.actions import formmodel_action
>>> @formmodel_action('My Label')
... def my_function(form_model, form):
...     # do something
...     pass

Providing and accessing actions


class dynamic_forms.actions.ActionRegistry

The ActionRegistry keeps track of all available actions available to the software. It is available to the outside through the action_registry singleton


You should not import the ActionRegistry directly! Always use the singleton instance action_registry!

>>> from dynamic_forms.actions import action_registry
register(func, label)

Registers the function func with the label label. The function will internally be referred by it’s full qualified name:

'%s.%s' % (func.__module__, func.__name__)
  • func (callable) – The function to register.
  • label (str) – A string / unicode giving the action a human readable name

Action registry utilities


Default Actions

dynamic_forms.actions.dynamic_form_send_email(form_model, form)

Sends the data submitted through the form form via e-mail to all recipients listed in DYNAMIC_FORMS_EMAIL_RECIPIENTS.

dynamic_forms.actions.dynamic_form_store_database(form_model, form)

Table Of Contents

Previous topic


Next topic


This Page