Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1049 from mfogel/remove-unescessary-parameter-checks

Remove unnecessary check on __set__ parameters.
  • Loading branch information...
commit f25fc5b2209b9c53cc0a71880ab049816f3a66a1 2 parents 2f8f2ad + a22e15e
@alex alex authored
View
6 django/contrib/contenttypes/generic.py
@@ -137,9 +137,6 @@ def __get__(self, instance, instance_type=None):
return rel_obj
def __set__(self, instance, value):
- if instance is None:
- raise AttributeError("%s must be accessed via instance" % self.related.opts.object_name)
-
ct = None
fk = None
if value is not None:
@@ -280,9 +277,6 @@ def __get__(self, instance, instance_type=None):
return manager
def __set__(self, instance, value):
- if instance is None:
- raise AttributeError("Manager must be accessed via instance")
-
manager = self.__get__(instance)
manager.clear()
for obj in value:
View
15 django/db/models/fields/related.py
@@ -206,9 +206,6 @@ def __get__(self, instance, instance_type=None):
return rel_obj
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
# ReverseSingleRelatedObjectDescriptor is annoying, but there's a bunch
# of small differences that would make a common base class convoluted.
@@ -312,9 +309,6 @@ def __get__(self, instance, instance_type=None):
return rel_obj
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
# to be an instance of the related class.
if value is None and self.field.null == False:
@@ -384,9 +378,6 @@ def __get__(self, instance, instance_type=None):
return self.related_manager_cls(instance)
def __set__(self, instance, value):
- if instance is None:
- raise AttributeError("Manager must be accessed via instance")
-
manager = self.__get__(instance)
# If the foreign key can support nulls, then completely clear the related set.
# Otherwise, just move the named objects into the set.
@@ -767,9 +758,6 @@ def __get__(self, instance, instance_type=None):
return manager
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:
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))
@@ -824,9 +812,6 @@ def __get__(self, instance, instance_type=None):
return manager
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:
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))
Please sign in to comment.
Something went wrong with that request. Please try again.