Form View — Pyramid Class-Based Views 1.0 documentation

# Form View

class `pyramid_views.views.edit.` `FormView`(**kwargs)

  A view for displaying a form, and rendering a template response.

  `success_url` = None
  `form_class` = None
  `get_form_class`()

    Returns the form class to use in this view

  `get_form`(form_class)

    Returns an instance of the form to be used in this view.

  `form_invalid`(form)

    If the form is invalid, re-render the context data with the data-filled form and errors.

  `form_valid`(form)

    If the form is valid, redirect to the supplied URL.

    Note

    Override this method if you wish to perform an action on successful form submission (Eg: For a contact form you may wish to send an email).

  `prefix` = None
  `get_prefix`()

    Returns the prefix to use for forms on this view

  `initial` = {}
  `get_initial`()

    Returns the initial data to use for forms on this view.

  `get_form_kwargs`()

    Returns the keyword arguments for instantiating the form.

  `template_name` = None
  `content_type` = None
  `get_context_data`(**kwargs)
  `macro_names` = None
  `get_macro_names`()

    Return a directory of macro names.

    Values should be template paths, and keys will be used as the lookup key in the template. Eg. `macros.<key>.<macro>`.

  `get`(request, *args, **kwargs)

    Handles GET requests and instantiates a blank version of the form.

  `post`(request, *args, **kwargs)

    Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.