Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5448: you can now use unicode characters in primary keys. Than…

…ks, pigletto.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6200 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit eea935a7f410b6ebda562d3d24d72f2b3fdda4b9 1 parent c998feb
Jacob Kaplan-Moss authored September 14, 2007
1  AUTHORS
@@ -232,6 +232,7 @@ answer newbie questions, and generally made Django that much better:
232 232
     phil@produxion.net
233 233
     phil.h.smith@gmail.com
234 234
     Gustavo Picon
  235
+    pigletto
235 236
     Luke Plant <http://lukeplant.me.uk/>
236 237
     plisk
237 238
     Daniel Poelzleithner <http://poelzi.org/>
4  django/db/models/base.py
@@ -12,7 +12,7 @@
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,7 +213,7 @@ def save(self, raw=False):
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.
5  tests/modeltests/custom_pk/models.py
... ...
@@ -1,3 +1,4 @@
  1
+# -*- coding: utf-8 -*-
1 2
 """
2 3
 14. Using a custom primary key
3 4
 
@@ -92,4 +93,8 @@ def __unicode__(self):
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
 """}

0 notes on commit eea935a

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