1👍
The easiest solution for the weighted rating would be to add an additional field and populate it automatically in a custom save
method on the rating object.
As far as getting the overall average rating goes, you can either calculate it dynamically every time it’s needed (easiest/most accurate method) using Django’s aggregation queries, or you can try to maintain an average rating field that is updated each time a rating is added/deleted/updated (the more performant method if you’re running a read-heavy service). See my answer here for more details on implementing these (using sums rather than averages) and more detail on the tradeoffs.
0👍
If you do not want to create a separate field that you need to maintain by overriding the save method, you need to follow this slightly more complex approach: Using .aggregate() on a value introduced using .extra(select={…}) in a Django Query?
- [Answer]-Dynamically deploy django admin app
- [Answer]-Djangobook ch 7 CSRF
- [Answer]-Admin.autodiscover() throwing TypeError in urls.py class