> Folks, > > I'd really love to be able to do something like this: > {% if videoObject.rating > 0 %}*{% endif %} > {% if videoObject.rating > 1 %}*{% endif %} > {% if videoObject.rating > 2 %}*{% endif %} > > To display an appropriate number of stars for a video clip in a > template. > > Right now, I'm resorting to creating n-element lists for each video, > where n corresponds to the video's rating, and then using a for loop to > cycle through those lists and display a star for each loop cycle. This > is horrible. It makes for a proliferation of barely used list objects, > and it makes both my view and my template code hard to read. > > Am I missing something? Why can't I do an actual comparison inside of > an if tag? Can I fix this or use some other tag or download some patch > or...? > > Thanks, > Mae
How about adding a method to your Video model? Video model: def get_rating_stars(self): return "***" # Implementation left as an exercise for the reader ;-) Template: {{ videoObject.get_rating_stars }} Jonathan. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---