mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #28418 -- Fixed queryset crash when using a GenericRelation to a proxy model.
This commit is contained in:
parent
c6986a4ebf
commit
f9e5f9ae9f
5 changed files with 16 additions and 1 deletions
|
@ -19,9 +19,15 @@ class Link(models.Model):
|
|||
return "Link to %s id=%s" % (self.content_type, self.object_id)
|
||||
|
||||
|
||||
class LinkProxy(Link):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class Place(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
links = GenericRelation(Link)
|
||||
link_proxy = GenericRelation(LinkProxy)
|
||||
|
||||
def __str__(self):
|
||||
return "Place: %s" % self.name
|
||||
|
|
|
@ -246,3 +246,8 @@ class GenericRelationTests(TestCase):
|
|||
def test_ticket_22982(self):
|
||||
place = Place.objects.create(name='My Place')
|
||||
self.assertIn('GenericRelatedObjectManager', str(place.links))
|
||||
|
||||
def test_filter_on_related_proxy_model(self):
|
||||
place = Place.objects.create()
|
||||
Link.objects.create(content_object=place)
|
||||
self.assertEqual(Place.objects.get(link_proxy__object_id=place.id), place)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue