Django

Code

Changeset 9550

Show
Ignore:
Timestamp:
12/02/08 16:09:51 (1 month ago)
Author:
lukeplant
Message:

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().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/fields/related.py

    r9546 r9550  
    176176    def __get__(self, instance, instance_type=None): 
    177177        if instance is None: 
    178             raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name 
     178            return self 
    179179 
    180180        try: 
     
    224224    def __get__(self, instance, instance_type=None): 
    225225        if instance is None: 
    226             raise AttributeError, "%s must be accessed via instance" % self.field.name 
     226            return self 
    227227        cache_name = self.field.get_cache_name() 
    228228        try: 
     
    288288    def __get__(self, instance, instance_type=None): 
    289289        if instance is None: 
    290             raise AttributeError, "Manager must be accessed via instance" 
     290            return self 
    291291 
    292292        rel_field = self.related.field 
     
    501501    def __get__(self, instance, instance_type=None): 
    502502        if instance is None: 
    503             raise AttributeError, "Manager must be accessed via instance" 
     503            return self 
    504504 
    505505        # Dynamically create a class that subclasses the related 
     
    546546    def __get__(self, instance, instance_type=None): 
    547547        if instance is None: 
    548             raise AttributeError, "Manager must be accessed via instance" 
     548            return self 
    549549 
    550550        # Dynamically create a class that subclasses the related