Opened 18 years ago

Closed 18 years ago

Last modified 16 years ago

#2201 closed defect (fixed)

TypeError: Cannot resolve keyword ___ into field

Reported by: dolemite@… Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: critical 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

For django svn revision 3156.
using sqlite-3.3.5

####So doing either of the following queries

Result.objects.filter(vulnerabilityconnected=True)
Result.objects.filter(Vulnerability
connected=True)

####for this type of model

class Vulnerability(models.Model):

requirement=models.ManyToManyField(Requirement)
result=models.ManyToManyField(Result)
connected=models.BooleanField('connected')

.
.
.

class Result(models.Model):

name= models.CharField(maxlength=200)

.
.
.
###would give me this error

Traceback (most recent call last):

File "<console>", line 1, in ?
File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/m

odels/query.py", line 88, in repr

return repr(self._get_data())

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 412, in _get_data

self._result_cache = list(self.iterator())

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 162, in iterator

select, sql, params = self._get_sql_clause()

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 426, in _get_sql_clause

tables2, joins2, where2, params2 = self._filters.get_sql(opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 557, in get_sql

tables2, joins2, where2, params2 = val.get_sql(opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 606, in get_sql

return parse_lookup(self.kwargs.items(), opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 716, in parse_lookup

tables2, joins2, where2, params2 = lookup_inner(path, clause, value, opts, opts.db_table, None)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 819, in lookup_inner

raise TypeError, "Cannot resolve keyword '%s' into field" % name

TypeError: Cannot resolve keyword 'vulnerability' into field

Change History (7)

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

This is not a bug. Use requirement_set, not Validation.

comment:2 by dolemite@…, 18 years ago

It is infact broken.
I did what you said on irc
I created a new project foobaz
I created a new app vb
I moved you model.py file into vb

I then executed
from vb.models import *

p1 = Publication(id=None, title='The Python Journal')
p1.save()
p2 = Publication(id=None, title='Science News')
p2.save()
p3 = Publication(id=None, title='Science Weekly')
p3.save()
a1 = Article(id=None, headline='Django lets you build Web apps easily')
a1.save()

a1.publications.add(p1)

a2 = Article(id=None, headline='NASA uses Python')
a2.save()
a2.publications.add(p1, p2)
a2.publications.add(p3)
a2.publications.add(p3)

new_publication = a2.publications.create(title='Highlights for Children')
a1.publications.all()
and got

:

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 412, in _get_data

self._result_cache = list(self.iterator())

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 162, in iterator

select, sql, params = self._get_sql_clause()

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 426, in _get_sql_clause

tables2, joins2, where2, params2 = self._filters.get_sql(opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 557, in get_sql

tables2, joins2, where2, params2 = val.get_sql(opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 606, in get_sql

return parse_lookup(self.kwargs.items(), opts)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 716, in parse_lookup

tables2, joins2, where2, params2 = lookup_inner(path, clause, value, opts, opts.db_table, None)

File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/query.py", line 819, in lookup_inner

raise TypeError, "Cannot resolve keyword '%s' into field" % name

TypeError: Cannot resolve keyword 'article' into field

comment:3 by anonymous, 18 years ago

Resolution: invalid
Status: closedreopened

comment:4 by dolemite@…, 18 years ago

Component: Database wrapperCore framework

Also the line
Publication.objects.filter(articleheadlinestartswith="NASA")
fails with
TypeError: Cannot resolve keyword 'article' into field

comment:5 by dolemite@…, 18 years ago

Sorry I am retarded
I was importing
app.model import *
not
project.app.model import *

comment:6 by anonymous, 18 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top