On Thursday, 21 November 2013 00:49:52 UTC, Timothy W. Cook wrote:
>
> Does the fact that I use a relat_name on the Review.paper field have
> anything to do with it not working?
>
> In the Review model, notice:
> paper = models.ForeignKey(Paper, verbose_name=_('Paper'),
> related_name="%(app_label)s_%(class)s_related+", null=False,
> blank=False, help_text=_("Select a paper."))
>
> In the annotation I tried:
> papers =
> Paper.objects.filter(project__id=self.kwargs['pk']).annotate(Count('papers_reviews_related+'))
>
>
>
>
The documentation for related_name
(https://docs.djangoproject.com/en/1.6/ref/models/fields/#django.db.models.ForeignKey.related_name)
states that if the value is, or ends with, "+", then no reverse
relationship will be created. I'm not sure why you are doing that, but
remove the "+" from the related_name in the ForeignKey definition.
--
DR.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/53a5d84f-cd6e-4464-a03d-1bf57d0e80c2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.