Django

Code

Ticket #5448 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Primary key can't be string with unicode characters

Reported by: pigletto Assigned to: pigletto
Milestone: Component: Core framework
Version: SVN Keywords: unicode primary key pk
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Model defined like:

class Actor(models.Model):

name = models.CharField?(max_length=20, primary_key=True)

when trying to save it:

travolta = Actor(name="Zażółć") travolta.save()

There is UnicodeDecodeError? at: django.db.base.Model -> save function:

File ".../lib/python2.4/site-packages/django/db/models/base.py", line 218, in save

pk_set = pk_val is not None and pk_val != u

UnicodeDecodeError?: 'ascii' codec can't decode byte 0xc5 in position 2: ordinal not in range(128)

fix should use smart_unicode like: pk_set = pk_val is not None and smart_unicode(pk_val) != u

Attachments

primary_unicode.diff (1.5 kB) - added by pigletto on 09/14/07 11:54:48.
Patch against revision 6193

Change History

09/14/07 04:40:40 changed by anonymous

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Is there a relationship with ticket:4725 (Quote problem with string primary keys in the admin panel) ?

09/14/07 04:59:22 changed by pigletto

I think it is not connected. Here, there is an issue with saving to rdbms and in 4725 the problem is with querying database and quoting

09/14/07 07:46:22 changed by pigletto

  • owner changed from nobody to pigletto.
  • status changed from new to assigned.

09/14/07 11:54:48 changed by pigletto

  • attachment primary_unicode.diff added.

Patch against revision 6193

09/14/07 12:01:46 changed by pigletto

  • has_patch set to 1.
  • stage changed from Unreviewed to Ready for checkin.

09/14/07 13:36:04 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [6200]) Fixed #5448: you can now use unicode characters in primary keys. Thanks, pigletto.


Add/Change #5448 (Primary key can't be string with unicode characters)




Change Properties
Action