Ticket #8248: help_fixes_with_foreignkeys_r8521.diff

File help_fixes_with_foreignkeys_r8521.diff, 1.8 KB (added by Manuel Saelices, 16 years ago)

Patch that fixes problem, but with a wrong approach

  • django/db/models/fields/related.py

     
    174174
    175175    def __get__(self, instance, instance_type=None):
    176176        if instance is None:
    177             raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name
     177            return self.related
    178178
    179179        try:
    180180            return getattr(instance, self.cache_name)
     
    222222
    223223    def __get__(self, instance, instance_type=None):
    224224        if instance is None:
    225             raise AttributeError, "%s must be accessed via instance" % self.field.name
     225            return self.field
    226226        cache_name = self.field.get_cache_name()
    227227        try:
    228228            return getattr(instance, cache_name)
     
    286286
    287287    def __get__(self, instance, instance_type=None):
    288288        if instance is None:
    289             raise AttributeError, "Manager must be accessed via instance"
     289            return self.related
    290290
    291291        rel_field = self.related.field
    292292        rel_model = self.related.model
     
    501501
    502502    def __get__(self, instance, instance_type=None):
    503503        if instance is None:
    504             raise AttributeError, "Manager must be accessed via instance"
     504            return self.related
    505505
    506506        # Dynamically create a class that subclasses the related
    507507        # model's default manager.
     
    546546
    547547    def __get__(self, instance, instance_type=None):
    548548        if instance is None:
    549             raise AttributeError, "Manager must be accessed via instance"
     549            return self.field
    550550
    551551        # Dynamically create a class that subclasses the related
    552552        # model's default manager.
Back to Top