mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #8248 - GenericRelations descriptors now return self when accessed via class
These were missed in r9550 git-svn-id: http://code.djangoproject.com/svn/django/trunk@9562 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -59,7 +59,7 @@ class GenericForeignKey(object):
|
|||||||
|
|
||||||
def __get__(self, instance, instance_type=None):
|
def __get__(self, instance, instance_type=None):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
raise AttributeError, u"%s must be accessed via instance" % self.name
|
return self
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return getattr(instance, self.cache_attr)
|
return getattr(instance, self.cache_attr)
|
||||||
@@ -183,7 +183,7 @@ class ReverseGenericRelatedObjectsDescriptor(object):
|
|||||||
|
|
||||||
def __get__(self, instance, instance_type=None):
|
def __get__(self, instance, instance_type=None):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
raise AttributeError, "Manager must be accessed via instance"
|
return self
|
||||||
|
|
||||||
# This import is done here to avoid circular import importing this module
|
# This import is done here to avoid circular import importing this module
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|||||||
Reference in New Issue
Block a user