BaseFormSet.total_error_count()
[source]
To check how many errors there are in the formset, we can use the total_error_count
method:
>>> # Using the previous example >>> formset.errors [{}, {'pub_date': ['This field is required.']}] >>> len(formset.errors) 2 >>> formset.total_error_count() 1
We can also check if form data differs from the initial data (i.e. the form was sent without any data):
>>> data = { ... 'form-TOTAL_FORMS': '1', ... 'form-INITIAL_FORMS': '0', ... 'form-MAX_NUM_FORMS': '', ... 'form-0-title': '', ... 'form-0-pub_date': '', ... } >>> formset = ArticleFormSet(data) >>> formset.has_changed() False
Please login to continue.