On Jun 8, 8:23 pm, Andy  Dietler <andydiet...@gmail.com> wrote:
> I'm trying to make one of the fields in my model display radio buttons
> with the options 1-5. I can't find a way to do this with a model form
> and I can't get anything I find in documentation to work properly.
>
> What I have below results in me getting the following error:
> TypeError: __init__() got an unexpected keyword argument 'widget'
>
> Any help would be much appreciated. - Andy
>
> rating_choices = (
>     (1, '1'),
>     (2, '2'),
>     (3, '3'),
>     (4, '4'),
>     (5, '5'),
> )
>
> class Rating(models.Model):
>     rating = models.IntegerField(widget=forms.RadioSelect
> (choices=rating_choices),label="")

You're confusing models and forms. You can't set things like widgets
on the model, you do that on a form.

You need to define a model form and override the definition of
'rating' to include the widget parameter. I presume you're looking to
use this in the admin, in which case you need to set the form
attribute of your rating admin class to the new form you've defined.
--
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to