Opened 19 years ago

Closed 19 years ago

#588 closed defect (invalid)

kwarg error when using get_object across join

Reported by: Boffbowsh Owned by: Adrian Holovaty
Component: Metasystem Version:
Severity: normal Keywords:
Cc: paul.bowsher@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Product (meta.Model):
	name = meta.TextField()

class Variant (meta.Model):
	product = meta.ForeignKey(Product)
>>> p = products.get_object(variant__id__exact=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.4/site-packages/django/utils/functional.py", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1094, in function_get_object
    obj_list = function_get_list(opts, klass, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1134, in function_get_list
    return list(function_get_iterator(opts, klass, **kwargs))
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1116, in function_get_iterator
    select, sql, params = function_get_sql_clause(opts, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1313, in function_get_sql_clause
    tables2, join_where2, where2, params2, _ = _parse_lookup(kwargs.items(), opts)
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1301, in _parse_lookup
    _throw_bad_kwarg_error(kwarg)
  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1192, in _throw_bad_kwarg_error
    raise TypeError, "got unexpected keyword argument '%s'" % kwarg
TypeError: got unexpected keyword argument 'variants__id__exact'

Also tried variant__id__exact, variant__pk etc

Change History (1)

comment:1 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: newclosed

That doesn't work, because the relationship works the other way.

variants.get_list(product__id__exact=1)

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