I ended up using the "divisibleby" filter and that worked out fine.
Thank you for both of your ideas!
I learn so much through this group.

Thank you very much.

Ryan Vanasse

On May 2, 9:27 pm, Pawel Pilitowski <[EMAIL PROTECTED]>
wrote:
> Maybe something like this would help:
>
> in the month loop:
>
> {% if forloop.counter|divisibleby:"2" %}
>         <img src="blue.gif">
> {% else %}
>         <img src="orange.gif">
> {% endif %}
>
> or try forloop.parentloop.counter if you need to get at it from you
> event loop.
>
> Cheers,
>
> Pawel
>
> On 03/05/2008, at 11:15 AM, Darryl Ross wrote:
>
> RyanVanassewrote:
> > Now, my problem is that for every month, I want a different color of
> > image text...
> > <img src="/static/Images/calendar/numbers/blue/{{Event.start_DateTime|
> > date:"j"}}.png" /> //blue/orange swap
> > so that on even months i'd have them come from the blue folder and odd
> > months they'd come from the orange folder (or something of that
> > nature). As far as I can tell, none of the default equality comparison
> > tags (if,ifequal, ifchanged?) would be able to select based on odd/
> > even. Count wouldn't work, I think, because it would change for each
> > individual event, instead of monthly.
>
> My first thought was {%cycle%}, but as you said, that would alternate
> for every event, even if one month had multiple events.
>
> What should work instead is to add a property to your Event model,
> which returns a boolean value based on if the month number is odd or
> even, and then you can use the standard if/else tag:
>
>    class Event(models.Model):
>      # ...
>      @property
>      def month_is_even(self):
>          return self.start_DateTime.month % 2 and False or True
>
> <img src="{% if event.month_is_even %}blue{% else %}orange{% endif
> %}.gif">
>
> That code is of course making the assumption that start_DateTime can
> never be Null, or you're likely to end up with an exception:
> "NullType has no property month"
>
> Cheers
> Darryl
>
> --
>
> Darryl Ross, VK5FUNE
> Director, AFOYI, "Information Technology Solutions"
> p +61 8 7127 1831
> f +61 8 8425 9607
> e [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to