Previous Page Next Page

Q&A

Q.Is there a way to determine if a Form object has errors from the template file?
A.Yes. If you access the has_errors attribute of a Form object in a template, it returns true if the form does not pass validation:
{% if pForm.has_errors %}
<p>Form Error. Please try again.</p>
{% endif %}

Q.Is there a way to modify the save function of a Form object to perform extra tasks before the save takes place?
A.Yes. The following code snippet from a Form class definition overrides the save() function:
class FormClass(forms.Form):
    . . . .
    def save(self):
        #Do Something
        super(FormClass, self).save()

Previous Page Next Page