Re: Random features in sidebar

2007-05-14 Thread Benjamin Slavin
On 5/14/07, Mordy Ovits <[EMAIL PROTECTED]> wrote: > And (after checking the python docs because I still think in Python > 1.5.2), random.sample() makes even more sense. For those interested, the snippet I posted (#230) has been updated to reflect the results of this discussion. - Ben --~--~-

Re: Random features in sidebar

2007-05-14 Thread Mordy Ovits
On Monday 14 May 2007 10:54 am, Mordy Ovits wrote: > I think it would make more sense to use random.shuffle() And (after checking the python docs because I still think in Python 1.5.2), random.sample() makes even more sense. Mordy --~--~-~--~~~---~--~~ You recei

Re: Random features in sidebar

2007-05-14 Thread Mordy Ovits
On Friday 11 May 2007 07:03 pm, Benjamin Slavin wrote: > I've just uploaded a template filter called "several_random" to the > django snippets site. > http://www.djangosnippets.org/snippets/230/ The way you're picking indices is inefficient: while len(picked_indices) < arg: candidate = random

Re: Random features in sidebar

2007-05-14 Thread Mordy Ovits
On Friday 11 May 2007 06:18 pm, orestis wrote: > Put in a simple, hard coded python list and use random on this ? Straight-up random will create dupes. My current thinking is to have python code creeate a list of 3 from 7 sidebar features and in the template have INCLUDEDs surrounded by IFs.

Re: Random features in sidebar

2007-05-11 Thread Benjamin Slavin
I've just uploaded a template filter called "several_random" to the django snippets site. [0] If you combine this with orestis's suggestion, I think you'll get what you're looking for. Quick side note: Using the built-in random filter in a template multiple times could give you the same result

Re: Random features in sidebar

2007-05-11 Thread orestis
Put in a simple, hard coded python list and use random on this ? You can put callables in the list that return the right info, so you can automate the stuff... On May 11, 10:44 pm, Mordy Ovits <[EMAIL PROTECTED]> wrote: > I have a sidebar in my page design. I have 7 or so features that can > go

Random features in sidebar

2007-05-11 Thread Mordy Ovits
I have a sidebar in my page design. I have 7 or so features that can go in a sidebar (links, quote of the day, infostat, on this day in history, etc.). I have models for each of those features. I can easily use django to have the template fill those out for every page, but what I want is to