Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefetch_related doesn't work #3

Open
gavinwahl opened this issue Nov 7, 2013 · 1 comment
Open

prefetch_related doesn't work #3

gavinwahl opened this issue Nov 7, 2013 · 1 comment

Comments

@gavinwahl
Copy link

Should you be able to include a ReverseUnique field in prefetch_related? Something like Lang.objects.all().prefetch_related('articletranslation_set__article__active_translation'). Currently this raises an error:

  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 96, in __iter__
    self._fetch_all()
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 856, in _fetch_all
    self._prefetch_related_objects()
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 517, in _prefetch_related_objects
    prefetch_related_objects(self._result_cache, self._prefetch_related_lookups)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 1598, in prefetch_related_objects
    obj_list, additional_prl = prefetch_one_level(obj_list, prefetcher, attr)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 1697, in prefetch_one_level
    prefetcher.get_prefetch_queryset(instances)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 277, in get_prefetch_queryset
    qs = self.get_queryset(instance=instances[0]).filter(**query)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 590, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 608, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1198, in add_q
    clause = self._add_q(where_part, used_aliases)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1232, in _add_q
    current_negated=current_negated)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1100, in build_filter
    allow_explicit_fk=True)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1351, in setup_joins
    names, opts, allow_many, allow_explicit_fk)
  File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1274, in names_to_path
    "Choices are: %s" % (name, ", ".join(available)))
FieldError: Cannot resolve keyword '+' into field. Choices are: abstract, article, body, id, lang, title
@akaariai
Copy link
Owner

akaariai commented Nov 7, 2013

All I can say is pull requests welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants