Code

Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#2201 closed defect (fixed)

TypeError: Cannot resolve keyword ___ into field

Reported by: dolemite@… Owned by: adrian
Component: Core (Other) Version: master
Severity: critical Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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

Attachments (0)

Change History (7)

comment:1 Changed 8 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:2 Changed 8 years ago by dolemite@…

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 Changed 8 years ago by anonymous

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:4 Changed 8 years ago by dolemite@…

  • Component changed from Database wrapper to Core framework

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

comment:5 Changed 8 years ago by dolemite@…

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

comment:6 Changed 8 years ago by anonymous

  • Resolution set to fixed
  • Status changed from reopened to closed

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.