diff --git a/django/db/models/fields/subclassing.py b/django/db/models/fields/subclassing.py
index 591adb7..43c3449 100644
a
|
b
|
class Creator(object):
|
30 | 30 | |
31 | 31 | def __get__(self, obj, type=None): |
32 | 32 | if obj is None: |
33 | | raise AttributeError('Can only be accessed via an instance.') |
| 33 | return self |
34 | 34 | return obj.__dict__[self.field.name] |
35 | 35 | |
36 | 36 | def __set__(self, obj, value): |
diff --git a/tests/field_subclassing/tests.py b/tests/field_subclassing/tests.py
index d3b4d9e..176d9bc 100644
a
|
b
|
|
1 | 1 | from __future__ import unicode_literals |
2 | 2 | |
| 3 | import inspect |
| 4 | |
3 | 5 | from django.core import serializers |
4 | 6 | from django.test import TestCase |
5 | 7 | |
… |
… |
class CustomField(TestCase):
|
90 | 92 | o = OtherModel.objects.get() |
91 | 93 | self.assertEqual(o.data.first, "a") |
92 | 94 | self.assertEqual(o.data.second, "b") |
| 95 | |
| 96 | def test_subfieldbase_plays_nice_with_module_inspect(self): |
| 97 | """ |
| 98 | Custom fields should play nice with python standard module inspect. |
| 99 | |
| 100 | http://users.rcn.com/python/download/Descriptor.htm#properties |
| 101 | """ |
| 102 | # even when looking for totally different properties, SubfieldBase it's |
| 103 | # non property like behaviour makes inspect crash. |
| 104 | strings = inspect.getmembers(MyModel, lambda x: type(x) is str) |
| 105 | known_strings = [('__module__', 'field_subclassing.models')] |
| 106 | |
| 107 | self.assertEqual(strings, known_strings) |
| 108 | |
| 109 | # should also not raise an exception |
| 110 | inspect.getmembers(MyModel) |