7.5 Putting It All Together

When first confronted by forms, many beginners try to fit the new tool under the umbrella of the Model-View-Controller (MVC) architecture. Because forms handle data, it’s common for beginners to associate forms with the Model portion of MVC. With a loose definition of MVC, where Models are simply any part of the framework that store and structure data, this is not wrong: the purpose of a form is to temporarily store data. However, the form is also meant to clean the data to ensure validity and secure the website and then to process it in some way (typically by adding it to the database), both of which are actions outside of Models purview. With the original, rather strict definition of MVC, forms don’t belong anywhere. ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.