Re: Problem using RadioSelect with newforms-admin

6 views
Skip to first unread message
Message has been deleted
Message has been deleted

Russell Keith-Magee

unread,
Jul 11, 2007, 10:38:16 PM7/11/07
to django-d...@googlegroups.com
On 7/12/07, leif strickland <leifstr...@gmail.com> wrote:
>
> Anyone? I've seen at least two threads related to this subject; I know
> I'm not the only one wondering.

Apologies for not getting back to you on this - I've been meaning to
take a look at the problem you are reporting, but I keep getting
distracted with other things.

At this point, the best approach would be to open a ticket, and
include a minimal example that demonstrates the problem. Otherwise
this issue will get lost in the flow.

Yours,
Russ Magee %-)

Russell Keith-Magee

unread,
Jul 12, 2007, 11:52:36 PM7/12/07
to django-d...@googlegroups.com
On 7/10/07, leif strickland <leifstr...@gmail.com> wrote:
>
> As you can see, the template is expecting a unicode object, but the
> RadioSelect widget returns a RadioFieldRenderer object.
>
> I was able to get around this problem by subclassing RadioSelect and
> adding to its render method:

I'm not getting the same problem. Here's my sample Admin class,
controlling a Poll/Choice example that has been augmented with a
'flavour' field (just so I can have something that needs a radio
option):

class PollAdmin(admin.ModelAdmin):
inlines = [admin.TabularInline(Choice, extra=2)]
fields = (
('main', {
'fields': ('question','participants','flavour'),
}),
)
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'flavour':
return
forms.ChoiceField(choices=FLAVOURS,widget=forms.RadioSelect,**kwargs)
else:
return
super(PollAdmin,self).formfield_for_dbfield(db_field,**kwargs)

Does this correlate with what your admin class, or have you done
something different?

Regarding your suggested fix: Looking at the code (r5628,
django/newforms/forms.py, line 259), a BoundField already contains a
similar code - when you render a bound field, it passes the rendered
output through unicode, with a comment specifically mentioning
RadioSelect.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages