Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 6ed780d commit 390e91db51ee48645a84117bfdcafce2744b5181 @malcolmt malcolmt committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 django/db/models/
4 django/db/models/
@@ -209,7 +209,9 @@ def save(self, raw=False):
# 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.

0 comments on commit 390e91d

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