Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread Cortland Klein
Yep that works, adding that and the following to forms.py: > from django.forms import fields > from django.db import models On Thu, Dec 18, 2008 at 11:53 AM, panta wrote: > > noticing you have provided also models.py, here is a more complete > answer: > > def my_formfield_cb(field): >if isin

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread Daniel Roseman
On Dec 18, 7:18 pm, Cortland Klein wrote: > I'm using inlineformset_factory in one of my views, which is working   > great, except now I'd like to change the widget for one of the fields   > (in case anyone's curious, an AdminFileWidget). For clarification this   > is my own view and has nothing

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread panta
noticing you have provided also models.py, here is a more complete answer: def my_formfield_cb(field): if isinstance(field, models.FileField) and field.name == 'file': return fields.FileField(widget = AdminFileWidget(attrs={'url': "/my/url/"})) return field.formfield() FileFormSe

Re: inlineformset_factory with a custom widget for a field

2008-12-18 Thread panta
I've never used inlineformset_factory(), but I guess you can use the formfield_callback parameter. For example: def my_formfield_cb(field): if condition_on_field(field): return SuitableFormField(widget = MyCustomWidget()) return field.formfield() FileFormSet = inlineformset_facto

inlineformset_factory with a custom widget for a field

2008-12-18 Thread Cortland Klein
I'm using inlineformset_factory in one of my views, which is working great, except now I'd like to change the widget for one of the fields (in case anyone's curious, an AdminFileWidget). For clarification this is my own view and has nothing to do with contrib/admin. I see that inlineformset