mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Refs #28856 -- Added test for caching of a GenericForeignKey pointing to a model that uses more than one level of MTI.
Forwardport of test and release notes of
3522203502 from stable/1.11.x
			
			
This commit is contained in:
		| @@ -17,3 +17,7 @@ Bugfixes | ||||
|  | ||||
| * Fixed incorrect foreign key constraint name for models with quoted | ||||
|   ``db_table`` (:ticket:`28876`). | ||||
|  | ||||
| * Fixed a regression in caching of a ``GenericForeignKey`` when the referenced | ||||
|   model instance uses more than one level of multi-table inheritance | ||||
|   (:ticket:`28856`). | ||||
|   | ||||
| @@ -17,3 +17,7 @@ Bugfixes | ||||
|  | ||||
| * Fixed incorrect foreign key constraint name for models with quoted | ||||
|   ``db_table`` (:ticket:`28876`). | ||||
|  | ||||
| * Fixed a regression in caching of a ``GenericForeignKey`` when the referenced | ||||
|   model instance uses more than one level of multi-table inheritance | ||||
|   (:ticket:`28856`). | ||||
|   | ||||
| @@ -38,6 +38,11 @@ class Restaurant(Place): | ||||
|         return "Restaurant: %s" % self.name | ||||
|  | ||||
|  | ||||
| class Cafe(Restaurant): | ||||
|     def __str__(self): | ||||
|         return "Cafe: %s" % self.name | ||||
|  | ||||
|  | ||||
| class Address(models.Model): | ||||
|     street = models.CharField(max_length=80) | ||||
|     city = models.CharField(max_length=50) | ||||
|   | ||||
| @@ -5,9 +5,10 @@ from django.forms.models import modelform_factory | ||||
| from django.test import TestCase, skipIfDBFeature | ||||
|  | ||||
| from .models import ( | ||||
|     A, Address, B, Board, C, CharLink, Company, Contact, Content, D, Developer, | ||||
|     Guild, HasLinkThing, Link, Node, Note, OddRelation1, OddRelation2, | ||||
|     Organization, Person, Place, Related, Restaurant, Tag, Team, TextLink, | ||||
|     A, Address, B, Board, C, Cafe, CharLink, Company, Contact, Content, D, | ||||
|     Developer, Guild, HasLinkThing, Link, Node, Note, OddRelation1, | ||||
|     OddRelation2, Organization, Person, Place, Related, Restaurant, Tag, Team, | ||||
|     TextLink, | ||||
| ) | ||||
|  | ||||
|  | ||||
| @@ -53,6 +54,11 @@ class GenericRelationTests(TestCase): | ||||
|         CharLink.objects.create(content_object=restaurant) | ||||
|         charlink = CharLink.objects.latest('pk') | ||||
|         self.assertIs(charlink.content_object, charlink.content_object) | ||||
|         # If the model (Cafe) uses more than one level of multi-table inheritance. | ||||
|         cafe = Cafe.objects.create() | ||||
|         CharLink.objects.create(content_object=cafe) | ||||
|         charlink = CharLink.objects.latest('pk') | ||||
|         self.assertIs(charlink.content_object, charlink.content_object) | ||||
|  | ||||
|     def test_q_object_or(self): | ||||
|         """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user