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:
parent
c998feb3bb
commit
eea935a7f4
1
AUTHORS
1
AUTHORS
@ -232,6 +232,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
phil@produxion.net
|
phil@produxion.net
|
||||||
phil.h.smith@gmail.com
|
phil.h.smith@gmail.com
|
||||||
Gustavo Picon
|
Gustavo Picon
|
||||||
|
pigletto
|
||||||
Luke Plant <http://lukeplant.me.uk/>
|
Luke Plant <http://lukeplant.me.uk/>
|
||||||
plisk
|
plisk
|
||||||
Daniel Poelzleithner <http://poelzi.org/>
|
Daniel Poelzleithner <http://poelzi.org/>
|
||||||
|
@ -12,7 +12,7 @@ from django.db.models.loading import register_models, get_model
|
|||||||
from django.dispatch import dispatcher
|
from django.dispatch import dispatcher
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.utils.functional import curry
|
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 django.conf import settings
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
import types
|
import types
|
||||||
@ -213,7 +213,7 @@ class Model(object):
|
|||||||
pk_val = self._get_pk_val()
|
pk_val = self._get_pk_val()
|
||||||
# Note: the comparison with '' is required for compatibility with
|
# Note: the comparison with '' is required for compatibility with
|
||||||
# oldforms-style model creation.
|
# 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
|
record_exists = True
|
||||||
if pk_set:
|
if pk_set:
|
||||||
# Determine whether a record with the primary key already exists.
|
# Determine whether a record with the primary key already exists.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
14. Using a custom primary key
|
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.objects.filter(employees__first_name__startswith='Fran')
|
||||||
[<Business: Sears>]
|
[<Business: Sears>]
|
||||||
|
|
||||||
|
# Primary key may be unicode string
|
||||||
|
>>> emp = Employee(employee_code='jaźń')
|
||||||
|
>>> emp.save()
|
||||||
|
|
||||||
"""}
|
"""}
|
||||||
|
Loading…
Reference in New Issue
Block a user