#20207 closed Bug (fixed)
`ManyToManyField` with an unicode name fails to create an intermediary model.
Reported by: | Simon Charette | Owned by: | Simon Charette |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
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
I encountered the following error when porting an app codebase to support both python 2 and 3.
from __future__ import unicode_literals class Teacher(models.Model): students_ = models.ManyToManyField(Student, name='students') # Here the name is a unicode string because of the future import.
Raises:
TypeError: Error when calling the metaclass bases type() argument 1 must be string, not unicode
The culprit is this line. It should always be a str
.
This was not introduced by the codebase port to Python 3 and thus it's not a release blocker.
Attaching a simple patch with tests in a few moments.
Attachments (1)
Change History (6)
by , 12 years ago
Attachment: | 0001-Fixed-20207-Handle-ManyToManyField-with-a-unicode-na.patch added |
---|
comment:1 by , 12 years ago
Has patch: | set |
---|
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:3 by , 12 years ago
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
It'd be nice to backport the fix to 1.5.