Code

Opened 7 years ago

Closed 7 years ago

#3444 closed (duplicate)

Symmetrical Many-to-Many all() failing

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

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!

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by flip.sasser@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.