basic error.
On Jun 27, 5:51 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Jun 27, 7:47 am, ses1984 <ses1...@gmail.com> wrote:
>
> > I am trying to use custom widgets in a model formset. I have tried to
> > achieve this by first defining the custom widget, then a form that
> > uses this widget, then passing this form as an argument to
> > modelformset_factory().
>
> > I don't think something is working right because if I check the type
> > of the form objects in my formset, the objects are my own custom
> > SliderInputs; however, when the very same formset is rendered, it
> > renders like the default widget. They don't render with any of the
> > content that I have added to the render method of SliderInput.
>
> > Below is the shell session demonstrating that I have SliderInput
> > widgets, then the actual class code that defines these.
>
> > I am using Django 1.1.1.
>
> Stop right there. Fromhttp://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#overrid...
>
> "New in Django 1.2: The widgets attribute is new in Django 1.2."
>
> You've successfully defined a widgets attribute on the form's Meta
> class, but Django is doing absolutely nothing with it, because 1.1
> doesn't know about it.
>
> Instead, you'll need to override the field definition at the form
> level:
>
> class WeightSliderForm(forms.ModelForm):
> amount = forms.FloatField(widget=SliderInput(attrs={
> 'max':'1000',
> 'min':'0',
> 'step':'.001',
> 'unit':'%',
> }))
> class Meta:
> model = Recipe
>
> --
> DR.
--
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.
No comments:
Post a Comment