Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Forms Forms Cleaning a Whole Form

Justyna Julia Jamr贸z
Justyna Julia Jamr贸z
13,354 Points

What super() does?

Can someone explain step by step how the super() function works?

1 Answer

Jacqueline McKinney
Jacqueline McKinney
2,627 Points

There is a link in the Teacher's notes that should help https://docs.djangoproject.com/en/1.9/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

"...ensures that any validation logic in parent classes is maintained."

super().clean() is called to make sure that the clean method that is normally called on form.Form (the parent class), before you overwrote it, is still called and any validation that it was going to do is preserved. And then you are adding to it your own validation. If you don't call it then you are responsible for all of the checks that would normally happen if you did not overwrite the function clean().