On Apr 15, 9:39 am, Baxter <mail.bax...@gmail.com> wrote:
> On Apr 15, 9:33 am, google torp <toppe...@gmail.com> wrote:> Hi.
> > You can just use the python random function, I believe it's in math,
> > and generate a random number in range of the number of articles.
> > You could do that before the slice even, and just get a random
> > number with min value of 2 instead.
>
> If I were smarter I'd understand what you're trying to tell me here.

Well, it got me on the right track, I think. I'm not entirely sure
what I've done here, so if it's stupid, someone please let me know:

subcat_articles = Article.objects.filter(publication='Published',
assigned_to=subcat).order_by('-id')[2:]
if subcat_articles.count() > 0:
                                subcat.article = choice(subcat_articles)

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