A URL field specifically for images, which can validate details about the filesize, dimensions and format of an image at a given URL, without having to read the entire image into memory.
Requires [Python Imaging Library](http://www.pythonware.com/library/pil/).
*4th October, 2008* - updated for 1.0 compatibility.
Have your forms descend from this BaseForm if you need to be able to render a valid form as hidden fields for re-submission, e.g. when showing a preview of something generated based on the form's contents.
Custom form example:
>>> from django import newforms as forms
>>> class MyForm(HiddenBaseForm, forms.Form):
... some_field = forms.CharField()
...
>>> f = MyForm({'some_field': 'test'})
>>> f.as_hidden()
u'<input type="hidden" name="some_field" value="test" id="id_some_field" />'
With `form_for_model`:
SomeForm = forms.form_for_model(MyModel, form=HiddenBaseForm)
Simple contact form, using a javascript form checker which you can use any you want to you can just modify the form in the way you want to.
The form checker I use I include in the 'base.html' page before the </head> section end. You can use it freely. http://media.xorl.de/form.js . A lot of this code is comprised of other peoples forms that didn't suit the simple purpose of a *really* basic contact form which I wanted, so I rebuilt it up from bits and pieces to make a simple basic form.
Wizard class - subclass this, supply a done() method and then you can use `MyWizard( [list, of, newforms, classes])` as a view function.
see [#3218](http://code.djangoproject.com/ticket/3218)
WTForm is an extension to the django newforms library allowing
the developer, in a very flexible way, to layout the form
fields using fieldsets and columns
WTForm was built with the well-documented [YUI Grid CSS](http://developer.yahoo.com/yui/grids/) in
mind when rendering the columns and fields. This should make
it easy to implement WTForm in your own applications.
Here is an image of an [example form rendered with WTForm](http://www.gmta.info/files/wtform.png).
The newforms package allows you to simply add new field types to your forms.
This snippet shows the addition of a new type of field, to make sure the user enters sensible currency values (either with no decimal, or two-decimal places), and a custom widget to make sure that the value is displayed correctly when the user sees the form.
The CurrencyInput widget simply tries to display the current value in floating point 2-decimal places format (and gives up if it can't). The CurrencyField makes sure that the input value matches a regular expression, and when it is asked to clean the value it converts it to a float.
The regex here limits the amount to 99,999.99 or less. This is within the bounds of accuracy of python's float value. If you want to use truly huge values for the amount, then you'll face problems with the floating point not being able to represent the values you enter, and so the conversion to floating point in the field will fail. In this case it would be better to use python longs, and used a fixed point interpretation.