**Now redundant any anything >0.96**, as `form_for_*` methods now have a `fields` attribute
`formfield_callback`s are a bit difficult to use, here's a helper method to create a callback function to use with the `form_for_instance` and `form_for_model` methods.
Example usage:
person_callback = new_callback(exclude=['password', 'can_add_staff', 'is_staff'])
def form_for_person(person):
return form_for_instance(person, formfield_callback=person_callback)
Useful for when you want to use an instance's values as the initial values of a form which you didn't use `form_for_instance` to create.
Handles foreign keys and many-to-many fields just fine.
I'm finding this much more efficient (from a coding perspective) than using the `render_to_response` shortcut.
It looks complex, but it's simple to use: just look at the example in the docstring.
Call this script `renderer.py` and chuck it in your project root.
Add a value to the context (inside of this block) for easy access.
Provides a way to stay DRYer in your templates.
**NOTE:** This tag is now in Django core, so if you have Django >0.96 (or SVN) then you do NOT need this.
Simple anti-spam field which will cause the form to raise a `ValidationError` if the value in this field changes. Displays as a CSS hidden `<input type="text" />` field.
If you specify a `class` in the `attrs` of the widget, the default `style="display:none;"` won't be rendered with the widget so that you can use a predefined CSS style to do your hiding instead. You can also cause the widget to be wrapped in an html comment to ensure it is not visible to the end user:
class EmailForm(Form):
email = EmailField()
website = HoneypotField(widget=HoneypotWidget(
attrs={'class':'fish'}, html_comment=True))