On Fri, 2007-12-21 at 06:48 -0800, mike wrote:
> Sorry if I was unclean, I just discovered this and I am still learning
> newforms, I am using forms.form_for_model and trying to get two form
> to display in my template, only 1 is a foreign key that I used
> edit_inline with my model, I am trying to get the 'customer' field of
> my issue to be hidden and automatically be given the 'name' field of
> my customer model, when I did what you suggested I get the error
> below, my view is below, thx for the suggestion

Use the formfield_callback attribute, which is a function that is called
for every field. It needs to return a newforms.field.* class.

The default definition of formfield_callback is 

        lambda f: f.formfield()
        
so your version should return f.formfield() (f is the single parameter
passed to the callback and is a django.db.models.fields.* instance) for
any fields you're not customising. If you are customising a field, you
do something like this:

        if f.name == 'customer':
           return f.formfield(formfclass=forms.HiddenInput)
        
Have a read of the code in django/db/models/fields/__init__.py to see
how formfield() methods work and play around a bit. As usual for Python,
five minutes of experimenting is more educational than pages of written
text.

Regards,
Malcolm

-- 
The sooner you fall behind, the more time you'll have to catch up. 
http://www.pointy-stick.com/blog/


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