I'm hoping someone can help me get the info I'm trying to get. This is
the structure:

I have Categories
    Each Category has one or more subcategory
    Articles have a M2M relationship with subcategory so they can turn
up in more than one category as needed.

I'm trying to get one random article for each category, but NOT the
two most recent articles.

I'm trying this:

articles = Article.objects.filter(publication='Published',
assigned_to=subcat).order_by('-id')[2:]
subcat.article = articles.order_by('?')[0]

Which should get all the articles for the subcat except the two most
recent ones, then select one random one from that list, except I'm
running into "AssertionError: Cannot reorder a query once a slice has
been taken."

So, how can I do this?
--~--~---------~--~----~------------~-------~--~----~
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