On 5/16/07, anders conbere <[EMAIL PROTECTED]> wrote:
>
> As far as I know the officially recommended way of accomplishing this
> while still using the form_for_* helper functions is through the use
> of a formfield_callback, a function that takes field instances and
> mucks with them.
>
> def form_callback(field, **kwargs):
>     if field.name == "field_name":
>         return None
>
> my_instance = MyClass.objects.get(pk=x)
> form = form_for_instance(instance, formfield_callback= form_callback)
>
> will remove the field named "field_name" from the form

Alternatively, you can use the recently added 'fields' attribute:

Form = form_for_instance(instance, fields=('field1','field2'))
myform = Form()

will produce a form for 'instance' that contains only the fields
'field1' and 'field2', populated with initial data from the instance.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to