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

  • Home
  • SEARCH
  • 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 3939852
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:20:54+00:00 2026-05-20T00:20:54+00:00

I’m working on a project that needs a ratings system where they can rate

  • 0

I’m working on a project that needs a ratings system where they can rate the quality of the houses. They’d be doing it from the admin panel, so it’s not something that a visitor would rate.

For example, for each listing, they can rate it from 1-5 stars:
Location:
Room:
Dining options:
Community:
Overall:

In my models.py file, I have this setup:

Class Listing (models.Model):

...

    RATING_CHOICES = (
        (1, 1),
        (2, 2),
        (3, 3),
        (4, 4),
        (5, 5),
    )
    location_rating = models.DecimalField(choices = RATING_CHOICES, max_digits=3, decimal_places=2)
    room_rating = models.DecimalField(choices = RATING_CHOICES, max_digits=3, decimal_places=2)
    dining_options_rating = models.DecimalField(choices = RATING_CHOICES, max_digits=3, decimal_places=2)
    community_rating = models.DecimalField(choices = RATING_CHOICES, max_digits=3, decimal_places=2)
    recreation_rooms_rating = models.DecimalField(choices = RATING_CHOICES, max_digits=3, decimal_places=2)
    def __unicode__(self):
        return self.name

    def get_avg_rating(self):
        avg_rating = (self.location_rating + self.room_rating + self.recreation_rooms_rating + self.dining_options_rating + self.community_rating) / 5
        return avg_rating

I’d plan to display the ratings with a little CSS. Just putting room_rating or avg_rating in a template tag doesn’t work, so I’m assuming I’d have to add some lines of code to views.py. I’ve checked the Django docs, but I’m still not sure how to go about this.

This seems like something that should be easy to do, but I’m not really sure where to start.

  • 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-20T00:20:55+00:00Added an answer on May 20, 2026 at 12:20 am

    A potential problem with the direction you taking is that you’re only storing one set of ratings for each Listing. If user B wants to rate a Listing, he’ll have to overwrite User A’s ratings. Instead of putting the ratings inside the Listing, you’ll need to break out your ratings into a separate Ratings table, and use a ManytoMany relationship between your Listings and Ratings. That way, you can have multiple users rate a particular listing, and then you can calculate and show the averages for each listing. See this discussion for reference.

    It might be better to use an existing ratings app than starting from scratch. They already have documentation so you can get them up and running quickly, and they handle the database design for you.

    Django Ratings

    Django Valuate

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.