1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #5448: you can now use unicode characters in primary keys. Thanks, pigletto.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6200 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2007-09-14 18:36:04 +00:00
parent c998feb3bb
commit eea935a7f4
3 changed files with 8 additions and 2 deletions

View File

@ -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 File

@ -12,7 +12,7 @@ from django.db.models.loading import register_models, get_model
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 @@ class Model(object):
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 File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
14. Using a custom primary key
@ -92,4 +93,8 @@ DoesNotExist: Employee matching query does not exist.
>>> Business.objects.filter(employees__first_name__startswith='Fran')
[<Business: Sears>]
# Primary key may be unicode string
>>> emp = Employee(employee_code='jaźń')
>>> emp.save()
"""}