On Mon, 2006-10-02 at 20:12 -0700, frank wrote: > > Malcolm Tredinnick wrote: > > On Mon, 2006-10-02 at 16:05 -0700, frank wrote: > > > I have a simple loop which sets up a series of radio-buttons. > > > "objgroup" is > > > obtained through a DB query/filter: > > > > > > {% for obj in objgroup %} > > > <P><INPUT TYPE=RADIO NAME="selected" VALUE={{ obj.id }} > > > {% ifequal seek_id obj.id %} CHECKED {% endifequal %} > > > > showing other things... </P> > > > {% endfor %} > > > > > > However the operation never indicates the desired default condition. > > > If I force an exception, I can see that the "seek_id" that I pass into > > > the > > > template has been forced into a list (as happens to everything). > > > Attributes > > > of objects, of course, don't get list-ified, so I speculate that this > > > is why > > > the comparison never succeeds even when the interior values would > > > appear to match. i.e.: [n] != n The obvious seek_id[0] fails, as > > > does > > > referring to it as {{seek_id}} within the {% ifequal...%}. > > > > > > This will probably be easier to diagnose if you can explain how seek_id > > is generated. We don't coerce everything into lists, so something is > > going on to make it a list at that point. So what does your view do to > > generate seek_id? > > > > Regards, > > Malcolm > > Sure -- seek_id is calculated in the view. It is delivered to the > template > via the second argument to render_to_response: { ..., "seek_id" : > value,...}.
Yes, I realised it came from the view like that. So my question wasn't clear. What have you said doesn't tell us what the seek_id value really *is*. Is it an integer, a string, an instance with methods? Can you print what type(seek_id) is before giving it to render_to_response just to check it really is what you are expecting. > Again, it's definitely not a list at that point, though it appears as > [value] > in the dump that occurs with an exception. Something strange is going on and that is why I am asking about seek_id. Django does not just convert things to lists if they aren't lists, so either you are passing in something like a QuerySet, whose string representation makes it looks like a list (are you using filter() instead of get() in a QuerySet for example?), or seek_id is not what you think it is. So put some debugging prints in the view and try to gather some more information about seek_id. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---