Package: django-formfactory
Django Form FactoryDynamic django form builder.ContentsDjango Form FactoryInstallationDependenciesUsageSettingsWidgets and FieldsViewsTemplatesInclusiontagModelsModel ChoicesActionsValidationAuthorsChangelog0.2.30.2.20.2.10.20.1InstallationInstall or adddjango-formfactoryto your Python path.Addformfactoryto yourINSTALLED_APPSsetting.Addurl(r'^formfactory/',include("formfactory.urls",namespace="formfactory"))to yoururl patterns(only required if you intend on using the detail view)DependenciesFormFactory makes use of the python markdown package as well as djano-simplemde. The latest tested version are pinned withinformfactory/tests/requirements/<django_version>.txtUsagedjango-formfactoryallows users to create forms and wizards in the CMS.SettingsFORMFACTORY[“field-types”]Control the form fields types that can be selected in Admin.
Supports adding none Django fields:("<module_for_field>","<display_name>")eg.("formfactory.fields.ParagraphField", "ParagraphField")FORMFACTORY[“widget-types”]Control the form widget types that can be selected in Admin.
Supports adding none Django widgets:("<module_for_widget>","<display_name>")eg.("formfactory.widgets.ParagraphWidget", "ParagraphWidget")Widgets and FieldsFormFactory ships with a ParagraphField and ParagraphWidget combo. The intended use for these is to allow copy to be added in between fields.
Allows for the same base templates to be used in most cases.Viewsdjango-formfactoryprovide a baseFormViewandFactoryWizardViewwhich can both be used directly or subclassed if you require extra context
or form data processing.Templatesdjango-formfactoryallows you to either override the template for all forms
by adding a templateformfactory/form_detail.htmlor an individual form by
adding a templateformfactory/form_detail_<form-slug>.htmlto your project’s
template dir. As well asformfactory/inclusion_tags/form_detail.htmlandformfactory/inclusion_tags/form_detail_<form-slug>.htmlfor the inclusion
tags.InclusiontagUse the inclusion tag which has been provided:{% render_form form_object %}ModelsFormData:A basic store for user submitted form data.uuid: a common uuid for each data item in the data setform: theFormobjectFormDataItem:A per field value store, encapsulated by aFormDataobject.form_data: theFormDataobjectform_field: theFormFieldobjectvalue: a text value of what was submitted for a particular fieldAction:An action which will be triggered in order when the form is saved.action: a choice of all registered actions in the projectas_function: a property which returns the action functionActionParam:Params that are required by the predefined or custom action functions. Passed to the action as a set of kwargs.key: param namevalue: param valueaction: theActionobjectForm:A form object which encapsulates a set of form fields and defines the actions that will be performed on save.title: a descriptive titleslug: url friendly identifieractions: a set ofActionobjects to be performed in order on savesuccess_message: The message string that will be displayed by the django messages framework on successful submission of the formfailure_message: The message string that will be displayed by the django messages framework if a form submission failsajax_post: Flag that enables JS ajax posting on the default formfactory templates, or to be used as a hook when overriding templates.Wizard:A wizard object that encapsulates a list of forms and actions that will be performed on the WizardView’sdonestep.title: a descriptive titleslug: url friendly identifierforms: a set of ordered forms mapping to each step in the WizardView.redirect_to: The URL which should should be redirect to after the wizard’s done step (e.g. “/”).actions: a set of orderedActionobjects to be performed in order in the WizardView’sdonestep.success_message: The message string that will be displayed by the django messages framework on successful submission of the formfailure_message: The message string that will be displayed by the django messages framework if a form submission failsEach form’ssave()method is called in thedonestep. This ensures that all actions defined for each form are
performed. Following that, wizard actions are then performed before the WizardView redirects.The URL to which the WizardView redirects can be specified in one of two ways:
- It can be specified in the CMS in theredirect_tofield on the wizard object.
- It can be specified as a GET query parameter on the URL. The query parameter key can be specified by settingFORMFACTORY["redirect-url-param-name"]in your settings file.FieldChoice:A set of field choices that a populated intoMultiSelectandSelectwidgetslabel: human readable dropdown labelvalue: the value that will be submittedFormFieldGroup:A model which encapsulates a set of form fields.title: the title to be used in the formset legend when renderedforms: theFormsthis grouping is associated toFormField:Defines a form field with all options and required attributes. Encapsulated by theFormobject.title: a descriptive titleslug: url friendly identifierposition: the position at which the field should be rendered in the formform_groups: theFormFieldGroupsthis field is associated tofield_type: a set of field type, defined in the app settingswidget: a set of widgets, defined in app settingslabel: the field label textinitial: an initial value the field will be populated withmax_length: the maximum length a value can behelp_text: a helpful string that will be rendered below the fieldplaceholder: a string that will be rendered as the field placeholderrequired: boolean value to indicate if the field is requireddisabled: boolean value to disable field (readonly)choices: a set ofFieldChoiceobjectsmodel_choices: a generic foreign key to a model which defines the choices for the formfieldadditional_validators: a set of custom defined field validatorsModel ChoicesTo define a custom model for field choices the model will need to have an items related name which points to an enum items model containing key and value fields.from django.db import models

class Enum(models.Model):
    title = models.CharField(max_length=100)

class EnumItem(models.Model):
    enum = models.ForeignKey(Enum, related_name="items")
    value = models.CharField(max_length=100)
    label = models.CharField(max_length=100)ActionsFormFactory come with some predefined actions:store_data: stores the submitted date to a key/value store_data. Requires noActionParamsend_email: sends the data via email. Requires the followingActionParamfrom_email_field: mapping to the form field that the email will be sent fromto_email_field: mapping to the form field that the email will be sent tosubject_field: mapping to the form field that will be used for the email subjectlogin: logs a user in. Requires the followingActionParamusername_field: mapping to the form field where the username will be completed.password_field: mapping to the form field where the username will be completed.file_upload: handles uploading files to a predefined path. Requires the followingActionParamupload_path_field: mapping to the form field where the upload path has been set.Custom actions can be added by creating a function in <yourapp or project>/formfactoryapp/actions.py. For example:from formfactory import actions

@actions.register
def my_custom_action(form_instance, **kwargs):
    # do some stuffValidationCustom validators can be added by creating a function in <yourapp or project>/formfactoryapp/validators.py. For example:from formfactory import validators

@validators.register
def my_custom_validator(value):
    if not condition:
        raise ValidationError("Failed")
    return TrueAuthorsPraekelt ConsultingJonathan BydendykPhala RamonyaiAltus BarryChangelog0.2.3Fix defaut None placeholder.0.2.2Fix setup.py syntax.0.2.1Added ParagraphField and ParagraphWidget.Added Paragraph markdown field on FormField model, for usage alongside field and widget.Added support for Fields and Widgets outside just base Django’s.Cater for order_by issue in Django 1.9 and 1.9.1.Data migration for field_type and widget fields on FormField.Add missing migrations.0.2Ajax form posting added.0.1Initial release.