Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1249 closed defect (fixed)

[magic-removal][patch] manipulator_validator_unique

Reported by: the.twentysixth@… Owned by: adrian
Component: Validators Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

self.original_object maybe None (e.g. in the case of AddManipulator)

Index: django/db/models/fields/__init__.py
===================================================================
--- __init__.py (revision 2051)
+++ __init__.py (working copy)
@@ -32,7 +32,8 @@
         old_obj = self.manager.get_object(**{lookup_type: field_data})
     except ObjectDoesNotExist:
         return
-    if hasattr(self, 'original_object') and self.original_object._get_pk_val() 
== old_obj._get_pk_val():
+    if hasattr(self, 'original_object') and hasattr(self.original_object, '_get
_pk_val') and \
+           self.original_object._get_pk_val() == old_obj._get_pk_val():
         return
     raise validators.ValidationError, _("%(optname)s with this %(fieldname)s al
ready exists.") % {'optname': capfirst(opts.verbose_name), 'fieldname': f.verbos
e_name}

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [2074]) magic-removal: Fixed #1249 -- Fixed bug in manipulator_validator_unique

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.