mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
- flake8 & black fixes
This commit is contained in:
parent
a5bec48ab4
commit
1be3ecf90a
@ -118,7 +118,8 @@ class ModelBase(type):
|
|||||||
else:
|
else:
|
||||||
new_attrs[obj_name] = obj
|
new_attrs[obj_name] = obj
|
||||||
new_class = super_new(cls, name, bases, new_attrs, **kwargs)
|
new_class = super_new(cls, name, bases, new_attrs, **kwargs)
|
||||||
# update contributable_attrs with any such attributes added to new_class - these came from __init_subclass__
|
# update contributable_attrs with any such attributes added to new_class.
|
||||||
|
# any such attributes came from user-defined __init_subclass__ on new_class
|
||||||
for obj_name, obj in dict(vars(new_class)).items():
|
for obj_name, obj in dict(vars(new_class)).items():
|
||||||
if _has_contribute_to_class(obj):
|
if _has_contribute_to_class(obj):
|
||||||
contributable_attrs[obj_name] = obj
|
contributable_attrs[obj_name] = obj
|
||||||
|
@ -255,17 +255,17 @@ class ModelInheritanceTests(TestCase):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __init_subclass__(cls, author_model_cls, **kwargs):
|
def __init_subclass__(cls, author_cls, **kwargs):
|
||||||
super().__init_subclass__(**kwargs)
|
super().__init_subclass__(**kwargs)
|
||||||
cls.author = models.ForeignKey(author_model_cls, on_delete = models.CASCADE)
|
cls.author = models.ForeignKey(author_cls, on_delete=models.CASCADE)
|
||||||
|
|
||||||
class Author(models.Model):
|
class Author(models.Model):
|
||||||
name = models.CharField(max_length = 256, unique = True)
|
name = models.CharField(max_length=256, unique=True)
|
||||||
|
|
||||||
class Book(BaseBookModel, author_model_cls = Author):
|
class Book(BaseBookModel, author_cls=Author):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertIsInstance(Book._meta.get_field('author'), models.ForeignKey)
|
self.assertIsInstance(Book._meta.get_field("author"), models.ForeignKey)
|
||||||
|
|
||||||
@isolate_apps("model_inheritance")
|
@isolate_apps("model_inheritance")
|
||||||
def test_set_name(self):
|
def test_set_name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user