Hi,

Is it possible to clear the variable 'errors' of a form object? If so,
could some one please help me in clearing the errors variable.

I have tried by below scenarios but, of no use.
form1.errors = {}
form1.errors = ''

Here is the code and output details:

class SearchForm(forms.Form):
    looking_for = forms.CharField(label="looking_for", required=True,
max_length=30)
    ageFrom = forms.IntegerField(label="ageFrom", required=False,
max_length=30)

My form1 object holds SearchForm class.

def searchView(request, redirect_field_name=REDIRECT_FIELD_NAME):
    redirect_to = request.REQUEST.get(redirect_field_name, '')
    if request.method == "POST":
       form1 = SearchForm(request.POST)
       print 'form1 error -', form1.errors

       for field in form1.errors:
          print 'field is ', field
       form1.errors = {} --> here I would like to clear the error
messages set by django

    else:
       form1 = SearchForm(request.POST)

    return render_to_response("search.html", {"form1":form1})


output for the above loop:
form2 error -  <ul class="errorlist"><li>looking_for<ul
class="errorlist"><li>This field is required.</li></ul></li></ul>
field is - looking_for



Regards,
Lokesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to