Archive for the 'newforms' Category

Using djangos newforms

If you start a django-app just now (January 2007) you are in a dilemma since using the old form engine is discouraged:

If you’re starting from scratch, we strongly encourage you not to waste your time learning this

But then, the documentation of new form engine, called “newforms”, isn’t complete at all.

You may argue «take a framework above 1.0», and you’d probably be right. As I wanted to stick with django, I implemented form handling the hard way by figuring out how to use newforms.

Anyway, as I finally got formhandling working with newforms, I thought I’d share this with you, my fellow readers..

The following code..

screenshot of the form
this examples’ form after validating user input
  • ..displays a form
  • ..validates user input
  • ..shows validation errors
  • ..writes the user data into the database

(more…)