Opened 18 years ago

Closed 18 years ago

#3444 closed (duplicate)

Symmetrical Many-to-Many all() failing

Reported by: flip.sasser@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi, I've noticed that in the current development version, symmetrical many-to-many relationships can call all() AT MOST one time. Using the supplied example supplied in the documentation, I get the following:

>>> from core.models import *                     
>>> a = Person(name='Anne')
>>> a.save()
>>> b = Person(name='Bill')
>>> b.save()
>>> c = Person(name='Chuck')
>>> c.save()
>>> d = Person(name='David')
>>> d.save()
>>> a.friends.add(b,c)
>>> d.friends.add(a,c)
>>> a.friends.all()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 101, in __repr__
    return repr(self._get_data())
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 444, in _get_data
    self._result_cache = list(self.iterator())
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 177, in iterator
    select, sql, params = self._get_sql_clause()
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 458, in _get_sql_clause
    joins2, where2, params2 = self._filters.get_sql(opts)
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 618, in get_sql
    joins2, where2, params2 = val.get_sql(opts)
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 669, in get_sql
    return parse_lookup(self.kwargs.items(), opts)
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 789, in parse_lookup
    joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None)
  File "/sw/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py", line 890, in lookup_inner
    raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'person' into field
>>> 

This problem does not exist in pre-0.96 Django distributions. As I am a Django newbie, there's not much I can do, but thanks for taking a look!

Change History (1)

comment:1 by flip.sasser@…, 18 years ago

Resolution: duplicate
Status: newclosed

My bad everyone; please don't hate me for accidentally re-opening old tickets.

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