Thursday, June 23, 2011

Custom form on formset does not use Meta 'widgets', bug?

Django dev, Python 2.6.6

Just wondering if I should file a bug report or am I just doing
something wrong.

I have an inline:


class ProductImageInline(admin.StackedInline):
model = ProductImage
formset = ProductImageFormset


...the form declaration and formset factory call:


class ProductImageForm(forms.ModelForm):

class Meta:
model = ProductImage
widgets = {
'picture': AdminImageJCropWidget(auto_enable=True,
jcrop_options=JCROP_OPTIONS)
}

ProductImageFormset = inlineformset_factory(Product, ProductImage,
form=ProductImageForm,

formset=BaseJCropImageFormset, extra=3)


The widgets declaration on the Meta class is not sticking. Bug?


However, if I add a formfield_overrides to my inline, it works:

class NewProductImageInline(admin.StackedInline):
model = ProductImage
formset = ProductImageFormset

formfield_overrides = {
models.ImageField: {'widget':
AdminImageJCropWidget(auto_enable=True, jcrop_options=JCROP_OPTIONS)},
}


The former looks like it should work and I prefer it over the latter
method, can anyone shed some light on this for me?

Thanks.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate