Yesterday I finally wrote my first Django application, this application is a basic crud that contains two pages, one to list costumers and another to change costumer data.
My biggest challenge was related with some form features, with Django forms you can programatically create a view form that contains several fields with its constraints and optionally associate a Django widget with this field. Django forms also have a very powerful validation engine and some form field constraints must be defined for this purpose.
This application uses the same page for two purposes, to add new data or edit data, in this scenario I must use a hidden field to be used as flag indicating in which mode the page is, adding or editing data, I must also change the readonly attribute of input widget used by costumer id form field since the user can’t change costumer id.
(more…)