summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorVlad Starostin <drtyrsa@yandex.ru>2014-05-16 14:25:45 +0200
committerTim Graham <timograham@gmail.com>2014-05-16 10:40:07 -0400
commit1be03aff5c24e902b89503dda32891aa4881579e (patch)
treeca29e88203cf95e278ce7e77bbb2559571c0a4da /django
parentddd52b221c5b005e42db3177f25a6b81561dea63 (diff)
Fixed #18389 -- Fixed the way contribute_to_class is called
Now this method is only called only if the object is an instance. This allows to have field classes as model class attributes.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 386986359d..bc41149a09 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import copy
+import inspect
import sys
from functools import update_wrapper
import warnings
@@ -299,7 +300,8 @@ class ModelBase(type):
cls.add_to_class(mgr_name, new_manager)
def add_to_class(cls, name, value):
- if hasattr(value, 'contribute_to_class'):
+ # We should call the contirbute_to_class method only if it's bound
+ if not inspect.isclass(value) and hasattr(value, 'contribute_to_class'):
value.contribute_to_class(cls, name)
else:
setattr(cls, name, value)