Hacker News new | comments | show | ask | jobs | submit login
Doing things with Django forms (uswaretech.com)
38 points by icey 2142 days ago | 4 comments

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.


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).


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.


Nice summary.


Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact