diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2008-12-10 00:14:56 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2008-12-10 00:14:56 +0000 |
| commit | 24a1900b3699fe883b027cfacfd7fe9ff117491f (patch) | |
| tree | 474b4d011602ce4ef55d9a94b63dc53f48a2424c /django/db/models | |
| parent | c9a6c06de89682386461fbf0071ba884983115f6 (diff) | |
[1.0.X] Fixed #8248: made help() work on models and improved introspection support.
Descriptors now return themselves when accessed via the class, as per standard
Python descriptors like property().
Backported from r9550 and also r9562 and r9563
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9634 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/fields/related.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index c87b823a69..146a1ae457 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -175,7 +175,7 @@ class SingleRelatedObjectDescriptor(object): def __get__(self, instance, instance_type=None): if instance is None: - raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name + return self try: return getattr(instance, self.cache_name) @@ -223,7 +223,7 @@ class ReverseSingleRelatedObjectDescriptor(object): def __get__(self, instance, instance_type=None): if instance is None: - raise AttributeError, "%s must be accessed via instance" % self.field.name + return self cache_name = self.field.get_cache_name() try: return getattr(instance, cache_name) @@ -287,7 +287,7 @@ class ForeignRelatedObjectsDescriptor(object): def __get__(self, instance, instance_type=None): if instance is None: - raise AttributeError, "Manager must be accessed via instance" + return self rel_field = self.related.field rel_model = self.related.model @@ -500,7 +500,7 @@ class ManyRelatedObjectsDescriptor(object): def __get__(self, instance, instance_type=None): if instance is None: - raise AttributeError, "Manager must be accessed via instance" + return self # Dynamically create a class that subclasses the related # model's default manager. @@ -545,7 +545,7 @@ class ReverseManyRelatedObjectsDescriptor(object): def __get__(self, instance, instance_type=None): if instance is None: - raise AttributeError, "Manager must be accessed via instance" + return self # Dynamically create a class that subclasses the related # model's default manager. |
