mirror of
https://github.com/django/django.git
synced 2025-11-25 13:13:28 +00:00
Refs #31223 -- Added __class_getitem__() to ForeignKey.
This commit is contained in:
parent
eeb0bb6379
commit
0de89b6f8d
2 changed files with 6 additions and 0 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue