Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@jacobian jacobian authored
View
1  AUTHORS
@@ -232,6 +232,7 @@ answer newbie questions, and generally made Django that much better:
phil@produxion.net
phil.h.smith@gmail.com
Gustavo Picon
+ pigletto
Luke Plant <http://lukeplant.me.uk/>
plisk
Daniel Poelzleithner <http://poelzi.org/>
View
4 django/db/models/base.py
@@ -12,7 +12,7 @@
from django.dispatch import dispatcher
from django.utils.datastructures import SortedDict
from django.utils.functional import curry
-from django.utils.encoding import smart_str, force_unicode
+from django.utils.encoding import smart_str, force_unicode, smart_unicode
from django.conf import settings
from itertools import izip
import types
@@ -213,7 +213,7 @@ def save(self, raw=False):
pk_val = self._get_pk_val()
# Note: the comparison with '' is required for compatibility with
# oldforms-style model creation.
- pk_set = pk_val is not None and pk_val != u''
+ pk_set = pk_val is not None and smart_unicode(pk_val) != u''
record_exists = True
if pk_set:
# Determine whether a record with the primary key already exists.
View
5 tests/modeltests/custom_pk/models.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""
14. Using a custom primary key
@@ -92,4 +93,8 @@ def __unicode__(self):
>>> Business.objects.filter(employees__first_name__startswith='Fran')
[<Business: Sears>]
+# Primary key may be unicode string
+>>> emp = Employee(employee_code='jaźń')
+>>> emp.save()
+
"""}
Please sign in to comment.
Something went wrong with that request. Please try again.