﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22992	"""'GenericForeignKey' object has no attribute 'get_lookup'"" exception on 1.7"	glicerinu@…	nobody	"Current 1.7 breaks querying by content_object on a model with generic relations.

{{{
>>> MonitorData.objects.get(content_object=site)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py"", line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 345, in get
    clone = self.filter(*args, **kwargs)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 689, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/query.py"", line 707, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py"", line 1287, in add_q
    clause, require_inner = self._add_q(where_part, self.used_aliases)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py"", line 1314, in _add_q
    current_negated=current_negated, connector=connector)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py"", line 1186, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py"", line 1092, in build_lookup
    final_lookup = lhs.get_lookup(lookup)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/sql/datastructures.py"", line 25, in get_lookup
    return self.output_field.get_lookup(name)
AttributeError: 'GenericForeignKey' object has no attribute 'get_lookup'
}}}


MonitorData looks like:


{{{
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType

class MonitorData(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    value = models.PositiveIntegerField()
    
    content_object = GenericForeignKey()
}}}
"	Bug	closed	contrib.contenttypes	1.7-rc-1	Release blocker	fixed	contenttypes GenericForeignKey get_lookup		Ready for checkin	1	0	0	0	0	0
