Opened 17 years ago
Closed 17 years ago
#5448 closed (fixed)
Primary key can't be string with unicode characters
Reported by: | Maciej Wiśniowski | Owned by: | Maciej Wiśniowski |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | unicode primary key pk | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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 (1)
Change History (6)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
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
comment:3 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 17 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Is there a relationship with ticket:4725 (Quote problem with string primary keys in the admin panel) ?