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
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
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
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
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
5 matches
Mail list logo