Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #8248: made help() work on models and improved introspe…

…ction 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
  • Loading branch information...
commit 24a1900b3699fe883b027cfacfd7fe9ff117491f 1 parent c9a6c06
Luke Plant authored December 10, 2008
2  django/contrib/admin/validation.py
@@ -36,6 +36,8 @@ def validate(cls, model):
36 36
                         except models.FieldDoesNotExist:
37 37
                             raise ImproperlyConfigured("%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r."
38 38
                                 % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))
  39
+                    else:
  40
+                        # getattr(model, field) could be an X_RelatedObjectsDescriptor
39 41
                         f = fetch_attr(cls, model, opts, "list_display[%d]" % idx, field)
40 42
                         if isinstance(f, models.ManyToManyField):
41 43
                             raise ImproperlyConfigured("'%s.list_display[%d]', '%s' is a ManyToManyField which is not supported."
4  django/contrib/contenttypes/generic.py
@@ -59,7 +59,7 @@ def get_content_type(self, obj=None, id=None):
59 59
 
60 60
     def __get__(self, instance, instance_type=None):
61 61
         if instance is None:
62  
-            raise AttributeError, u"%s must be accessed via instance" % self.name
  62
+            return self
63 63
 
64 64
         try:
65 65
             return getattr(instance, self.cache_attr)
@@ -183,7 +183,7 @@ def __init__(self, field):
183 183
 
184 184
     def __get__(self, instance, instance_type=None):
185 185
         if instance is None:
186  
-            raise AttributeError, "Manager must be accessed via instance"
  186
+            return self
187 187
 
188 188
         # This import is done here to avoid circular import importing this module
189 189
         from django.contrib.contenttypes.models import ContentType
10  django/db/models/fields/related.py
@@ -175,7 +175,7 @@ def __init__(self, related):
@@ -223,7 +223,7 @@ def __init__(self, field_with_rel):
@@ -287,7 +287,7 @@ def __init__(self, related):
@@ -500,7 +500,7 @@ def __init__(self, related):
@@ -545,7 +545,7 @@ def __init__(self, m2m_field):

0 notes on commit 24a1900

Please sign in to comment.
Something went wrong with that request. Please try again.