Django

Code

Changeset 5934

Show
Ignore:
Timestamp:
08/18/07 22:23:31 (1 year ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/base.py

    r5933 r5934  
    210210        # First, try an UPDATE. If that doesn't update anything, do an INSERT. 
    211211        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'' 
    213215        record_exists = True 
    214216        if pk_set: