Refs #31223 -- Added __class_getitem__() to ForeignKey.

This commit is contained in:
Collin Anderson 2022-04-22 08:13:12 -04:00 committed by GitHub
parent eeb0bb6379
commit 0de89b6f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -978,6 +978,9 @@ class ForeignKey(ForeignObject):
)
self.db_constraint = db_constraint
def __class_getitem__(cls, *args, **kwargs):
return cls
def check(self, **kwargs):
return [
*super().check(**kwargs),

View File

@ -164,3 +164,6 @@ class ForeignKeyTests(TestCase):
class MyModel(models.Model):
child = models.ForeignKey(1, models.CASCADE)
def test_manager_class_getitem(self):
self.assertIs(models.ForeignKey["Foo"], models.ForeignKey)