mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #14334 -- Query relation lookups now check object types.
Thanks rpbarlow for the suggestion; and loic, akaariai, and jorgecarleitao for reviews.
This commit is contained in:
parent
81edf2d006
commit
34ba86706f
6 changed files with 144 additions and 21 deletions
|
@ -409,6 +409,15 @@ class ObjectA(models.Model):
|
|||
return self.name
|
||||
|
||||
|
||||
class ProxyObjectA(ObjectA):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class ChildObjectA(ObjectA):
|
||||
pass
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ObjectB(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
@ -419,11 +428,17 @@ class ObjectB(models.Model):
|
|||
return self.name
|
||||
|
||||
|
||||
class ProxyObjectB(ObjectB):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ObjectC(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
objecta = models.ForeignKey(ObjectA, null=True)
|
||||
objectb = models.ForeignKey(ObjectB, null=True)
|
||||
childobjecta = models.ForeignKey(ChildObjectA, null=True, related_name='ca_pk')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue