Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:17+00:00 2026-05-27T21:46:17+00:00

I use a voting app (django-ratings if that makes any difference) which uses django’s

  • 0

I use a voting app (django-ratings if that makes any difference) which uses django’s GenericForeignKey, has a ForeignKey to User, and several other fields like date of latest change.

I’d like to get all the objects of one content type, that a single user voted for ordered by date of latest change. As far as I understand – all the info can be found in a single table (except the content_type which can be prefetched/cached). Unfortunately django still makes an extra query each time I request a content_object.

So the question is – how do I get all the votes on a given model, by a given user, with related objects and given ordering with minimum database hits?

Edit: Right now I’m using 2 queries – first selecting all the votes, getting all the objects I need, filtering by .filter(pk__in=obj_ids) and finally populating them to votes objects. But it seems that a reverse generic relation can help solve the problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:46:18+00:00Added an answer on May 27, 2026 at 9:46 pm

    Well right now we’re using prefetch_related() from django 1.4 on a GenericRelation. It still uses 2 queries, but has a very intuitive interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any good rating and voting script tutorials that use PHP and MySQL?
I'm working on an app that has up and down voting similar to StackExchange.
I am working on a App that makes use of a JSON API and
I am making a django app with comments and voting on those comments, in
I'm trying to use the django-voting tutorial from this blog: http://new.justinlilly.com/blog/2008/nov/04/django-voting-a-brief-tutorial/ to get a
I have a Django site using a 5-star rating system for voting (I use
I'm sure you're all familiar with the voting systems that use AJAX (Um... look
Is there any plug-in that i can use with vBulletin to add thumbs up
How would I be able to use the Drupal Fivestar voting module for voting
I have installed django-ratings application in my django project. Am wondering how best can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.