Ticket #5448: primary_unicode.diff
File primary_unicode.diff, 1.5 KB (added by , 17 years ago) |
---|
-
django/db/models/base.py
12 12 from django.dispatch import dispatcher 13 13 from django.utils.datastructures import SortedDict 14 14 from django.utils.functional import curry 15 from django.utils.encoding import smart_str, force_unicode 15 from django.utils.encoding import smart_str, force_unicode, smart_unicode 16 16 from django.conf import settings 17 17 from itertools import izip 18 18 import types … … 213 213 pk_val = self._get_pk_val() 214 214 # Note: the comparison with '' is required for compatibility with 215 215 # oldforms-style model creation. 216 pk_set = pk_val is not None and pk_val!= u''216 pk_set = pk_val is not None and smart_unicode(pk_val) != u'' 217 217 record_exists = True 218 218 if pk_set: 219 219 # Determine whether a record with the primary key already exists. -
tests/modeltests/custom_pk/models.py
1 # -*- coding: utf-8 -*- 1 2 """ 2 3 14. Using a custom primary key 3 4 … … 92 93 >>> Business.objects.filter(employees__first_name__startswith='Fran') 93 94 [<Business: Sears>] 94 95 96 # Primary key may be unicode string 97 >>> emp = Employee(employee_code='jaźń') 98 >>> emp.save() 99 95 100 """}