I don’t know when it popped up, but as I’ve been working on a new Django project, I’ve been noticing the newforms documentation page. Today, I decided to check it out. I am quite impressed with what newforms do. The “old style” “automatic” form handling in Django revolved around database Model object and “manipulators” (which you could create from a Model). Form handling was closely tied to your database model. Indeed, form handling was closely tied to the Django ORM.

New style “automatic” form handling revolves around a Form object. Said Form object is apparently decoupled from the Django ORM. (I suspect this was a necessary step in order to integrate SQLAlchemy and any other non-Django ORM.) Here is an awesome little tutorial on using newforms.

Some of the benefits of using newforms are

  • Less code in your view
  • Less code in your template. I forgot to mention that newforms automatically generate HTML. Including errors! Very nice…
  • Easily swap out form input “widgets”.
  • Easily ties to an database model…or not.

If you can’t tell, I’m really worked up about newforms. Django just got a whole lot cooler. I’m sure I’ll write more on this later.