Re:Doing things with Django forms
by old-gregg on Thursday January 14, 2010 @05:52PM
(#1053777)
Forms are the biggest difference between Rails itself and Rails-inspired Python frameworks (I'm talking about Pylons's default helpers, Toscawidgets and Django here)
After working with Rails for 3 years I am absolutely don't get the need for "form" classes. And indeed, judging by open sourced projects and posted code examples, submit handlers in Django and Pylons always look insanely complex as compared to Rails.
Re:Doing things with Django forms
by kgrin on Thursday January 14, 2010 @06:51PM
(#1053876)
Django isn't Rails-inspired - they were developed at around the same time, with no real awareness of each other (at first).
As to the merits of "form" classes and post handlers, I think the complexity is only there if you need it, if you're doing something more interesting (read: complex) than CRUD-type inserts/updates and basic validation (if that's all you're doing, ModelForms are pretty close to magical and light on syntax).
Re:Doing things with Django forms
by kaveri on Friday January 15, 2010 @07:01AM
(#1054714)
Django forms (and their non-Django counterpart, WTForms) are very easy to use, with a declarative syntax.
The advantage is that validation is decoupled from models. Often you need to handle validation which doesn't directly involve a single model - for example sending an email, or handling updates to a number of models. This saves you having to litter your controller/views with validation code.
After working with Rails for 3 years I am absolutely don't get the need for "form" classes. And indeed, judging by open sourced projects and posted code examples, submit handlers in Django and Pylons always look insanely complex as compared to Rails.
As to the merits of "form" classes and post handlers, I think the complexity is only there if you need it, if you're doing something more interesting (read: complex) than CRUD-type inserts/updates and basic validation (if that's all you're doing, ModelForms are pretty close to magical and light on syntax).
The advantage is that validation is decoupled from models. Often you need to handle validation which doesn't directly involve a single model - for example sending an email, or handling updates to a number of models. This saves you having to litter your controller/views with validation code.