Message from discussion
newforms-admin: defaults and radio select
Received: by 10.35.73.10 with SMTP id a10mr1016399pyl.1184013283876;
Mon, 09 Jul 2007 13:34:43 -0700 (PDT)
Received: by g4g2000hsf.googlegroups.com with HTTP;
Mon, 09 Jul 2007 20:34:42 +0000 (UTC)
X-IP: 71.70.239.198
From: _ <allen.ridd...@gmail.com>
To: Django users <django-users@googlegroups.com>
Subject: Re: newforms-admin: defaults and radio select
Date: Mon, 09 Jul 2007 13:34:42 -0700
Message-ID: <1184013282.797480.103870@g4g2000hsf.googlegroups.com>
In-Reply-To: <1184001782.123771.20260@z28g2000prd.googlegroups.com>
References: <1183948699.393500.83800@c77g2000hse.googlegroups.com>
<1183958309.126455.281840@d30g2000prg.googlegroups.com>
<1183979548.289557.297010@r34g2000hsd.googlegroups.com>
<1184001782.123771.20260@z28g2000prd.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.4) Gecko/20061201 Firefox/2.0.0.4 (Ubuntu-feisty),gzip(gfe),gzip(gfe)
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Thanks for the code, I'll give it a shot.
As for initial values, I'm thinking about the add form. I'm sorry, I
should have said.
On Jul 9, 1:23 pm, leifbyron <leifstrickl...@gmail.com> wrote:
> Hi Allen,
>
> The RadioSelect widget is actually one of the more complicated ones in
> newforms. Its render method returns a RadioFieldRenderer object, which
> in turn utilizes the RadioInput widget. The problem with using a
> RadioSelect widget in newforms-admin is that the template is expecting
> each widget to produce a unicode string, not a non-string object. So
> when the RadioSelect widget returns a RadioFieldRenderer object to the
> template, an error is triggered.
>
> Luckily, this problem is easy to fix by subclassing RadioSelect like
> so:
>
> class AdminRadioSelect(forms.widgets.RadioSelect):
> def render(self, name, value, attrs=None, choices=()):
> renderer =
> super(AdminRadioSelect,self).render(name,value,attrs,choices)
> return renderer.__unicode__()
>
> This, of course, is pretty hackish. I am not sure if a ticket is open
> to solve this problem. But at least this code suffices for now.
>
> As for initial values ... are you referring to the values of a saved
> object as rendered on a change form, or the default values (as defined
> in the model) on the add form?
>
> Leif