#1796: [patch] "Cannot resolve keyword ___ into field" error when working with
ManyToMany relation
-------------------------+--------------------------------------------------
Reporter: anonymous | Owner: mtredinnick
Status: reopened | Component: Database wrapper
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------+--------------------------------------------------
Changes (by Robin Breathe):
* cc: [EMAIL PROTECTED] (added)
Comment:
I am seeing this problem manifest with current SVN/r4724 both when
accessing the admin page for a standard auth_user and interactively from
the python shell. The problem appears to be expanding the user.groups
relation.
Shell:
{{{
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username__startswith='name')
>>> u
<User: [EMAIL PROTECTED]>
>>> u.groups
<django.db.models.fields.related.ManyRelatedManager object at 0x6c4490>
>>> u.groups.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 102, in __repr__
return repr(self._get_data())
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 468, in _get_data
self._result_cache = list(self.iterator())
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 172, in iterator
select, sql, params = self._get_sql_clause()
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 482, in _get_sql_clause
joins2, where2, params2 = self._filters.get_sql(opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 646, in get_sql
joins2, where2, params2 = val.get_sql(opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 697, in get_sql
return parse_lookup(self.kwargs.items(), opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 829, in parse_lookup
joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts,
opts.db_table, None)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py", line 936, in lookup_inner
raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'user' into field
}}}
Admin:
{{{
Traceback (most recent call last):
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/core/handlers/base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/contrib/admin/views/decorators.py" in _checklogin
55. return view_func(request, *args, **kwargs)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/views/decorators/cache.py" in _wrapped_view_func
39. response = view_func(request, *args, **kwargs)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/contrib/admin/views/main.py" in change_stage
363. new_data = manipulator.flatten_data()
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/manipulators.py" in flatten_data
248. new_data.update(f.flatten_data(fol, obj))
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/fields/related.py" in flatten_data
700. instance_ids = [instance._get_pk_val() for instance in getattr(obj,
self.name).all()]
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in __iter__
108. return iter(self._get_data())
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in _get_data
468. self._result_cache = list(self.iterator())
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in iterator
172. select, sql, params = self._get_sql_clause()
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in _get_sql_clause
482. joins2, where2, params2 = self._filters.get_sql(opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in get_sql
646. joins2, where2, params2 = val.get_sql(opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in get_sql
697. return parse_lookup(self.kwargs.items(), opts)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in parse_lookup
829. joins2, where2, params2 = lookup_inner(path, lookup_type, value,
opts, opts.db_table, None)
File "/app/python/2.5.0/lib/python2.5/site-
packages/django/db/models/query.py" in lookup_inner
936. raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError at /admin/auth/user/2/
Cannot resolve keyword 'user' into field
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/1796#comment:47>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---