Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating readme

  • Loading branch information...
commit 0bf0b47ad40d57cf5487e56d37891279cbefa224 1 parent 2650528
Charles Leifer authored May 01, 2012

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  README.rst
8  README.rst
Source Rendered
@@ -5,6 +5,8 @@ django-generic-aggregation
5 5
 annotate() and aggregate() for generically-related data.  also a handy function
6 6
 for filtering GFK-model querysets.
7 7
 
  8
+the use of annotate() and aggregate() require a ``GenericRelation``.
  9
+
8 10
 Examples
9 11
 --------
10 12
 
@@ -15,7 +17,7 @@ You want the most commented on blog entries::
15 17
     >>> from blog.models import BlogEntry
16 18
     >>> from generic_aggregation import generic_annotate
17 19
 
18  
-    >>> annotated = generic_annotate(BlogEntry.objects.all(), Comment.content_object, Count('id'))
  20
+    >>> annotated = generic_annotate(BlogEntry.objects.all(), Comment, Count('comments__id'))
19 21
 
20 22
     >>> for entry in annotated:
21 23
     ...    print entry.title, entry.score
@@ -37,11 +39,11 @@ You want to figure out which items are highest rated::
37 39
     Rating.objects.create(content_object=apple, rating=5)
38 40
     Rating.objects.create(content_object=apple, rating=7)
39 41
 
40  
-    >>> aggregate = generic_aggregate(Food.objects.all(), Rating.content_object, Sum('rating'))
  42
+    >>> aggregate = generic_aggregate(Food, Rating, Sum('ratings__rating'))
41 43
     >>> print aggregate
42 44
     15
43 45
 
44  
-    >>> aggregate = generic_aggregate(Food.objects.all(), Rating.content_object, Avg('rating'))
  46
+    >>> aggregate = generic_aggregate(Food, Rating.objects.all(), Avg('ratings__rating'))
45 47
     >>> print aggregate
46 48
     5
47 49
 

0 notes on commit 0bf0b47

Please sign in to comment.
Something went wrong with that request. Please try again.