summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2017-06-04 22:58:24 +0100
committerTim Graham <timograham@gmail.com>2017-06-05 08:40:43 -0400
commited244199c72f5bbf33ab4547e06e69873d7271d0 (patch)
tree727afbd26e655449ebcd007fe5f64333dd2b9711 /django
parent36f09c8a29eaad6a7e903ddc3ea1e8b5954ee67a (diff)
Fixed #28269 -- Fixed Model.__init__() crash on models with a field that has an instance only descriptor.
Regression in d2a26c1a90e837777dabdf3d67ceec4d2a70fb86.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/options.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 82d96b739c..90462278d9 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -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)