Remove unnecessary check on __set__ parameters.
This commit is contained in:
parent
bc46f67fa8
commit
a22e15effc
|
@ -137,9 +137,6 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
return rel_obj
|
return rel_obj
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("%s must be accessed via instance" % self.related.opts.object_name)
|
|
||||||
|
|
||||||
ct = None
|
ct = None
|
||||||
fk = None
|
fk = None
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
@ -280,9 +277,6 @@ class ReverseGenericRelatedObjectsDescriptor(object):
|
||||||
return manager
|
return manager
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("Manager must be accessed via instance")
|
|
||||||
|
|
||||||
manager = self.__get__(instance)
|
manager = self.__get__(instance)
|
||||||
manager.clear()
|
manager.clear()
|
||||||
for obj in value:
|
for obj in value:
|
||||||
|
|
|
@ -206,9 +206,6 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri
|
||||||
return rel_obj
|
return rel_obj
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("%s must be accessed via instance" % self.related.opts.object_name)
|
|
||||||
|
|
||||||
# The similarity of the code below to the code in
|
# The similarity of the code below to the code in
|
||||||
# ReverseSingleRelatedObjectDescriptor is annoying, but there's a bunch
|
# ReverseSingleRelatedObjectDescriptor is annoying, but there's a bunch
|
||||||
# of small differences that would make a common base class convoluted.
|
# of small differences that would make a common base class convoluted.
|
||||||
|
@ -312,9 +309,6 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
|
||||||
return rel_obj
|
return rel_obj
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("%s must be accessed via instance" % self.field.name)
|
|
||||||
|
|
||||||
# If null=True, we can assign null here, but otherwise the value needs
|
# If null=True, we can assign null here, but otherwise the value needs
|
||||||
# to be an instance of the related class.
|
# to be an instance of the related class.
|
||||||
if value is None and self.field.null == False:
|
if value is None and self.field.null == False:
|
||||||
|
@ -384,9 +378,6 @@ class ForeignRelatedObjectsDescriptor(object):
|
||||||
return self.related_manager_cls(instance)
|
return self.related_manager_cls(instance)
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("Manager must be accessed via instance")
|
|
||||||
|
|
||||||
manager = self.__get__(instance)
|
manager = self.__get__(instance)
|
||||||
# If the foreign key can support nulls, then completely clear the related set.
|
# If the foreign key can support nulls, then completely clear the related set.
|
||||||
# Otherwise, just move the named objects into the set.
|
# Otherwise, just move the named objects into the set.
|
||||||
|
@ -767,9 +758,6 @@ class ManyRelatedObjectsDescriptor(object):
|
||||||
return manager
|
return manager
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("Manager must be accessed via instance")
|
|
||||||
|
|
||||||
if not self.related.field.rel.through._meta.auto_created:
|
if not self.related.field.rel.through._meta.auto_created:
|
||||||
opts = self.related.field.rel.through._meta
|
opts = self.related.field.rel.through._meta
|
||||||
raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name))
|
raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name))
|
||||||
|
@ -824,9 +812,6 @@ class ReverseManyRelatedObjectsDescriptor(object):
|
||||||
return manager
|
return manager
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if instance is None:
|
|
||||||
raise AttributeError("Manager must be accessed via instance")
|
|
||||||
|
|
||||||
if not self.field.rel.through._meta.auto_created:
|
if not self.field.rel.through._meta.auto_created:
|
||||||
opts = self.field.rel.through._meta
|
opts = self.field.rel.through._meta
|
||||||
raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name))
|
raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name))
|
||||||
|
|
Loading…
Reference in New Issue