mirror of
https://github.com/django/django.git
synced 2025-10-04 07:46:37 +00:00
Fixed #28269 -- Fixed Model.__init__() crash on models with a field that has an instance only descriptor.
Regression in d2a26c1a90
.
This commit is contained in:
parent
36f09c8a29
commit
ed244199c7
4 changed files with 21 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
import copy
|
||||
import inspect
|
||||
import warnings
|
||||
from bisect import bisect
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
@ -829,7 +830,9 @@ class Options:
|
|||
@cached_property
|
||||
def _property_names(self):
|
||||
"""Return a set of the names of the properties defined on the model."""
|
||||
return frozenset({
|
||||
attr for attr in
|
||||
dir(self.model) if isinstance(getattr(self.model, attr), property)
|
||||
})
|
||||
names = []
|
||||
for name in dir(self.model):
|
||||
attr = inspect.getattr_static(self.model, name)
|
||||
if isinstance(attr, property):
|
||||
names.append(name)
|
||||
return frozenset(names)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue