Hello,
I have a model
class Post(models.Model):
...
authors = models.ManyToManyField('accounts.User', through='PostAuthor', related_name='authors_posts')
class PostAuthor(models.Model):
user = models.ForeignKey('accounts.User')
post = models.ForeignKey(Post)
...
How can I use the Django 1.7 Prefetch object to load PostAuthors, this
does not work:
Post.objects.prefetch_related(
Prefetch(
'authors',
queryset=PostAuthors.object.select_related('user')
)
I got an exception:
django.core.exceptions.FieldError: Cannot resolve keyword 'authors_posts' into field. Choices are: created, id, post, post_id,
user, user_id
Thanks for help,
Marcin Szamotulski
--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/20140127014254.GB10613%40flying-circus.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment