Hello,

I've ran into a situation where I might need a random generator in my templates.
I'm aware that the default template tag set doesn't support any random 
generator.
Previous attempts in adding one to the default set where ignored because off 
out of scope issues with the standard set.

Anyway here's my case.

I've got some queryset which I want to display. Each item has 3 possible visual 
presentation modes or way's it's might be displayed.
I could simply append some random data in my views.py file to the result set. 

gigs = Gig.objects.filter(date__gt = date.today()).order_by('date')[:17]

for gig in gigs:
    #append the random item to each result
   # This doesn't seem like a sensible solution and it I'm not even sure if 
it's even possible appending some data to a querset


Next I would check the random data in my template and act upon it.





My other idea is a random generator in my template tags.

something like

{% random %}
<div id="possiblity1">{{gig.data}}</div>
{% or %}
<div id="possiblity2">{{gig.data}}</div>
etc ...
{% endrandom %}

This behavior is mimicked after: 
http://code.djangoproject.com/attachment/ticket/919/random_tag.patch

Is this a sensible solution ? 

Or are there other better way's of solving random issues in the template layer ?

Regards,

Jonas.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to