Commits

James Bennett committed 1d8cf1d

Clean up view documentation a bit

  • Participants
  • Parent commits c7d7db4

Comments (0)

Files changed (2)

File contact_form/views.py

                  template_name='contact_form/contact_form.html',
                  success_url='/contact/sent/', fail_silently=False):
     """
-    Renders a contact form, validates its input and sends an email
+    Render a contact form, validate its input and send an email
     from it.
+
+    **Optional arguments:**
+
+    ``fail_silently``
+        If ``True``, errors when sending the email will be silently
+        supressed (i.e., with no logging or reporting of any such
+        errors. Default value is ``False``.
+
+    ``form_class``
+        The form to use. If not supplied, this will default to
+        ``contact_form.forms.ContactForm``. If supplied, the form
+        class must implement a method named ``save()`` which sends the
+        email from the form; the form class must accept an
+        ``HttpRequest`` as the keyword argument ``request`` to its
+        constructor, and it must implement a method named ``save()``
+        which sends the email and which accepts the keyword argument
+        ``fail_silently``.
+
+    ``success_url``
+        The URL to redirect to after a successful submission. If not
+        supplied, this will be the URL ``/contact/sent/``.
+
+    ``template_name``
+        The template to use for rendering the contact form. If not
+        supplied, defaults to
+        :template:`contact_form/contact_form.html`.
+
+    **Context:**
+
+    ``form``
+        The form instance.
     
-    To specify the form class to use, pass the ``form_class`` keyword
-    argument; if no ``form_class`` is specified, the base
-    ``ContactForm`` class will be used.
-    
-    To specify the template to use for rendering the form (*not* the
-    template used to render the email message sent from the form,
-    which is handled by the form class), pass the ``template_name``
-    keyword argument; if not supplied, this will default to
-    ``contact_form/contact_form.html``.
-    
-    To specify a URL to redirect to after a successfully-sent message,
-    pass the ``success_url`` keyword argument; if not supplied, this
-    will default to ``/contact/sent/``.
-    
-    To suppress exceptions raised during sending of the email, pass a
-    ``True`` value for the ``fail_silently`` keyword argument. This is
-    **not** recommended.
-    
-    Template::
-    
-        Passed in the ``template_name`` argument.
-        
-    Context::
-    
-        form
-            The form instance.
-    
+    **Template:**
+
+    The value of the ``template_name`` keyword argument, or
+    :template:`contact_form/contact_form.html`.
+
     """
     if request.method == 'POST':
         form = form_class(data=request.POST, files=request.FILES, request=request)

File docs/views.txt

 ``contact_form.views.contact_form``
 ====================================
 
-Renders a contact form, validates its input and sends an email from
-it.
+Render a contact form, validate its input and send an email from it.
 
-To specify the form class to use, pass the ``form_class`` keyword
-argument; if no ``form_class`` is specified, the base ``ContactForm``
-class will be used.
+**Optional arguments:**
 
-To specify the template to use for rendering the form (*not* the
-template used to render the email message sent from the form, which is
-handled by the form class), pass the ``template_name`` keyword
-argument; if not supplied, this will default to
-``contact/contact_form.html``.
+``fail_silently``
+    If ``True``, errors when sending the email will be silently
+    supressed (i.e., with no logging or reporting of any such
+    errors. Default value is ``False``.
 
-To specify a URL to redirect to after a successfully-sent message,
-pass the ``success_url`` keyword argument; if not supplied, this will
-default to ``/contact/sent/``.
+``form_class``
+    The form to use. If not supplied, this will default to
+    ``contact_form.forms.ContactForm``. If supplied, the form class
+    must implement a method named ``save()`` which sends the email
+    from the form; the form class must accept an ``HttpRequest`` as
+    the keyword argument ``request`` to its constructor, and it must
+    implement a method named ``save()`` which sends the email and
+    which accepts the keyword argument ``fail_silently``.
 
-To suppress exceptions raised during sending of the email, pass a
-``True`` value for the ``fail_silently`` keyword argument. This is
-**not** recommended.
+``success_url``
+    The URL to redirect to after a successful submission. If not
+    supplied, this will be the URL ``/contact/sent/``.
+
+``template_name``
+    The template to use for rendering the contact form. If not
+    supplied, defaults to :template:`contact_form/contact_form.html`.
+
+**Context:**
+
+``form``
+    The form instance.
     
-Template::
+**Template:**
 
-    Passed in the ``template_name`` argument.
-    
-Context::
-
-    form
-        The form instance.
+The value of the ``template_name`` keyword argument, or
+:template:`contact_form/contact_form.html`.