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

~ Anders

On 5/15/07, John Matthew <[EMAIL PROTECTED]> wrote:
> James, thanks for the quick reply!
>
> Ok, I like what you have there, but it doesn't solve the problem of when I
> want to edit an existing record, how do I use the customform?  I guess I'm
> just missing something super simple here, no?
>
> I would think code like
>
> instance = objects.get(id=1)
> form = OrderForm(
> instance)
> does this get me the form filled with the data from instance?
>
> Thanks
>
>
> On 5/15/07, James Bennett <[EMAIL PROTECTED]> wrote:
> >
> > On 5/15/07, John M <[EMAIL PROTECTED]> wrote:
> > > When I put up the form for order, I don't want the Customer (foreign
> > > key) to appear.  I've not seen anything on the forum that shows you
> > > can easily eliminate a field from the form?
> >
> > In general, form_for_model and form_for_instance are for when you just
> > want "form for this thing" and don't care about fine-grained control
> > of the fields. When you do want fine-grained control of the fields, a
> > custom form is the way to go.
> >
> > > Unless I'm missing how to create a custom form, bind it to the DB's
> > > data and use it like I can form_for_instance() and form_for_model().
> >
> > Something like this is what you're looking for, I think:
> >
> > http://dpaste.com/10396/
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
> >
> >
>
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
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