Russ,

Thanks for info, but what happens when the form.save() is called,
since the FK isn't part of the clean_data, it will fail no?

I think i've gotten to the point where I can get it off the form, but
now how do I make it so I can update the FK in code on the POST?

Thanks everyone for continuing on this thread, but I still don't like
the portion of the newforms stuff, and I know it's not done, so I hope
this can help improve it.

The other option is using a charfield widget that is hidden with the
FK, but doesn't that lend myself to hacking?  I'm SO new to web stuff
that I don't want to write a site that is vulnerable.

John

On May 15, 7:31 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> 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 django-users@googlegroups.com
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