I just upgraded from Django 1.10 to 1.11.1. In my template new_house_edit.html, I have the following:
{{ form.rating }}
models.py contain the following:
class NewHouse(models.Model):
rating = models.IntegerField(choices=(
(1, "1"),
(2, "2"),
(3, "3"),
(4, "4"),
(5, "5"),
),
default=3
)
As forms.pyI did the following:
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
class NewHouseForm(forms.ModelForm):
class Meta:
model = NewHouse
fields = (
'rating',)
widgets={
"rating": forms.RadioSelect(renderer=HorizontalRadioRenderer),
}
Which gave the following error AttributeError: type object 'RadioSelect' has no attribute 'renderer'.I tried to solve it by doing this without working:
class HorizontalRadioSelect(forms.RadioSelect):
template_name = 'new_house_edit'
class NewHouseForm(forms.ModelForm):
class Meta:
model = NewHouse
fields = (
'rating',)
widgets={
"rating": "rating": forms.ChoiceField(widget=HorizontalRadioSelect, choices=(1, 2, 3, 4, 5)),
}
Now I get the error AttributeError: 'ChoiceField' object has no attribute 'use_required_attribute'. Can someone help me fix this?