Opened 4 years ago

Closed 4 years ago

#22339 closed Uncategorized (invalid)

accessing m2m relation where database is not 'default' throws error

Reported by: zzart999@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7-beta-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Giving two models
like here :
with m2m relation located on single database which is configured with a different alias then 'default'

Accessing relation a1.publications.all() throws error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/", line 191, in all
    return self.get_queryset()
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/fields/", line 874, in get_queryset
    return qs._next_is_sticky().filter(**self.core_filters)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/", line 686, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/", line 704, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1284, in add_q
    clause, require_inner = self._add_q(where_part, self.used_aliases)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1311, in _add_q
    current_negated=current_negated, connector=connector)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1138, in build_filter
    lookups, parts, reffed_aggregate = self.solve_lookup_type(arg)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1076, in solve_lookup_type
    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1380, in names_to_path
    self.raise_field_error(opts, name)
  File "/home/mars/dev/ve/v3/lib/python3.3/site-packages/django/db/models/sql/", line 1386, in raise_field_error
    "Choices are: %s" % (name, ", ".join(available)))
django.core.exceptions.FieldError: Cannot resolve keyword 'article' choices are .... 

Change History (3)

comment:1 Changed 4 years ago by anonymous

I've forgotten to add that this works in django 1.6.2 and stops working in django 1.7beta and current git master

comment:2 Changed 4 years ago by Anssi Kääriäinen

Severity: NormalRelease blocker

I don't have time to check this just now, but I'll mark this as a release blocker so that this will not be missed.

If possible, a small sample project or code for models + would help a lot in debugging this, from the description I am not exactly sure how to reproduce this.

comment:3 Changed 4 years ago by anonymous

Resolution: invalid
Status: newclosed

I've done some testing on clean install and the problem seems to be elsewhere. I can confirm the relation m2m lookups work as expected. I going to close this ticket and file another one if im able to pinpoint the bug mode precisely. Simple reinstall from ver. 1.6.2 to 1.7 causes the code to fall but at the moment it's not clear to me where the problem is ...

Note: See TracTickets for help on using tickets.
Back to Top