On Aug 16, 2006, at 7:12 AM, [EMAIL PROTECTED] wrote:
>
> Waylan,
>
> This is a really nifty solution, but, again, it puts presentation  
> logic
> into the views.py file, which is supposed to contain business logic.
> I'd rather not do that...


But nothing is ever so rigid as to require you do it one way or  
another. You could even use the string value to drive your  
presentation logic. Using a for loop, you can easily change the  
displayed character:

        {% for x in make_list object.get_rating_stars %}#{% endfor %}

And later, when you decide to use an image of a star, no code change  
is required:

        {% for x in make_list object.get_rating_stars %}
        <img src="star.gif" ... />
        {% endfor %}

I've seen sites that have solid and hollow stars to show 3 out of 5  
stars. So you can use the template code like this (assuming a string  
such as "***--"):

        {% for x in make_list object.get_rating_stars %}
                {% ifequal x '*' %}<img src="star.gif" ... />
                {% else %}<img src="hollow_star.gif" ... />
        {% endfor %}

I would probably rename the method to something like get_rating_string 
(), then you can return anything you'd like, "Zowie!" or "***", and  
display it however you want to.

Don


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to