Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5934 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 390e91db51ee48645a84117bfdcafce2744b5181 1 parent 6ed780d
Malcolm Tredinnick authored August 19, 2007

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  django/db/models/base.py
4  django/db/models/base.py
@@ -209,7 +209,9 @@ def save(self, raw=False):
209 209
 
210 210
         # First, try an UPDATE. If that doesn't update anything, do an INSERT.
211 211
         pk_val = self._get_pk_val()
212  
-        pk_set = pk_val is not None
  212
+        # Note: the comparison with '' is required for compatibility with
  213
+        # oldforms-style model creation.
  214
+        pk_set = pk_val is not None and pk_val != u''
213 215
         record_exists = True
214 216
         if pk_set:
215 217
             # Determine whether a record with the primary key already exists.

0 notes on commit 390e91d

Please sign in to comment.
Something went wrong with that request. Please try again.