Author: mtredinnick
Date: 2007-08-18 22:23:31 -0500 (Sat, 18 Aug 2007)
New Revision: 5934

Modified:
   django/trunk/django/db/models/base.py
Log:
Tweaked the unset primary key check from [5933] to accommodate models created 
in the oldforms style. It's a backwards-compatibility hack that we can remove 
when oldforms go away. See #2160 for discussion. Fixed #5204, #2160. Refs #5102.


Modified: django/trunk/django/db/models/base.py
===================================================================
--- django/trunk/django/db/models/base.py       2007-08-18 07:40:59 UTC (rev 
5933)
+++ django/trunk/django/db/models/base.py       2007-08-19 03:23:31 UTC (rev 
5934)
@@ -209,7 +209,9 @@
 
         # First, try an UPDATE. If that doesn't update anything, do an INSERT.
         pk_val = self._get_pk_val()
-        pk_set = pk_val is not None
+        # Note: the comparison with '' is required for compatibility with
+        # oldforms-style model creation.
+        pk_set = pk_val is not None and pk_val != u''
         record_exists = True
         if pk_set:
             # Determine whether a record with the primary key already exists.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to