Thanks for the idea, but that doesn't quite work either. If someone
only has 3 events, then the for loop runs through 3 times, and I end
up with only three TD's. I'm pretty sure what I need can't be
accomplished in template code.
I think I need to assign all the variables in view code, then send the
resulting information to the template. Something like:
for event in events.objects.all():
if event = "golfing", then golfer = "1"
else golfer ="0"
if event = "hiking', then hiker = "1"
else hiker = "0"
...
or something. I'll dig more, comparing data like this seems similar
to something someone would do for "tagging" posts in a blog
application. I'll start there.
On Jun 13, 6:40 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> You just need something like:
> {% for p in object.events.all %}
> {% if p.event_name %}
> <td>{{ p.event_name }},</td>
> {% else %}><td></td>
> {% endif %}
> {% endfor %}
>
> You could put the whole row in the IF, if you like.
>
> On Jun 12, 8:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > I think that requires more logic in the template than possible.
>
> > My brain says tot do exactly what you suggest. But my template looks
> > similar to this:
> > {% for p in object.events.all %}
> > <td>
> > {{ p.event_name }},
> > </td>
> > {% endfor %}
>
> > If the Member isn't registered to one of the events, then I don't get
> > a <td></td> for that event, and it throws off the rest of the format
> > for the table...
>
> > On Jun 12, 6:32 pm, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
>
> > > [snip
>
> > > > The trouble I'm having is, if someone is not assigned to an event, I
> > > > get nothing displayed (duh, there's not an event); except I'm
> > > > displaying this in a table, and if I don't have any data, then the
> > > > cell formatting doesn't line up correctly.
>
> > > [snip]
>
> > > I just quickly perused your email; if the only problem you are having is
> > > the loop creating the table row/column when there isn't any actual data,
> > > couldn't you just create an {% if object %} in the template, and adjust
> > > the formatting accordingly?
>
> > > Just a quick thought,
> > > Kelvin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---