﻿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
21559	Can no longer query reverse generic relations in Django 1.6	khoobks@…	nobody	"Please see the code below for a demonstration of the regression.

== The Model ==
{{{
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class TaggedItem(models.Model):
    tag = models.SlugField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    # On Python 3: def __str__(self):
    def __unicode__(self):
        return self.tag

class Bookmark(models.Model):
    url = models.URLField()
    tags = generic.GenericRelation(TaggedItem)
}}}

== The Setup ==
{{{
from test_app.models import *

b = Bookmark(url='https://www.djangoproject.com/')
b.save()
t1 = TaggedItem(content_object=b, tag='django')
t1.save()
t2 = TaggedItem(content_object=b, tag='python')
t2.save()
}}}

== Django 1.5 ==
{{{
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>> import django
>>> from test_app.models import *
>>> django.VERSION
(1, 5, 5, 'final', 0)
>>> TaggedItem.objects.filter(bookmark__url__icontains='django')
[<TaggedItem: django>, <TaggedItem: python>]
>>>
}}}

== Django 1.6 ==
{{{
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>>
>>> import django
>>> from test_app.models import *
>>> django.VERSION
(1, 6, 0, 'final', 0)
>>> TaggedItem.objects.filter(bookmark__url__icontains='django')
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\manager.py"", line 163, in f
ilter
    return self.get_queryset().filter(*args, **kwargs)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\query.py"", line 590, in fil
ter
    return self._filter_or_exclude(False, *args, **kwargs)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\query.py"", line 608, in _fi
lter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\sql\query.py"", line 1198, i
n add_q
    clause = self._add_q(where_part, used_aliases)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\sql\query.py"", line 1232, i
n _add_q
    current_negated=current_negated)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\sql\query.py"", line 1100, i
n build_filter
    allow_explicit_fk=True)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\sql\query.py"", line 1351, i
n setup_joins
    names, opts, allow_many, allow_explicit_fk)
  File ""C:\workspace\django_generic_relationship\django16\lib\site-packages\django\db\models\sql\query.py"", line 1274, i
n names_to_path
    ""Choices are: %s"" % (name, "", "".join(available)))
FieldError: Cannot resolve keyword 'bookmark' into field. Choices are: content_type, id, object_id, tag
>>>
}}}

I would have expected that the same code should work the same way between Django 1.5 and 1.6. "	Bug	closed	contrib.contenttypes	1.6	Normal	fixed		khoobks@…	Accepted	0	0	0	0	0	0
