I found it! The correct query shoud be
Book.objects.all().prefetch_related('price_set')
On Feb 7, 5:38 pm, Jonathanz <[email protected]> wrote:
> I'm using django1.4 from svn trunk.
> The models are as follows:
>
> class Book(models.Model):
> # some stuff
>
> class Price(models.Model):
> book = models.ForgeinKey(Book)
>
> Each book can have many prices.
>
> My query in view:
> Book.objects.all().prefetch_related('price')
>
> I got this error:
> Cannot find 'price' on Book object, 'price' is an invalid parameter to
> prefetch_related()
>
> Am I missing something? or prefetch_related cannot handle reverse
> lookup.
>
> Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.