`ManyToManyField` with an unicode name fails to create an intermediary model.
|Reported by:||charettes||Owned by:||charettes|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
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.
Change History (6)
Changed 2 years ago by charettes
comment:4 Changed 2 years ago by Simon Charette <charette.s@…>
- Resolution set to fixed
- Status changed from new to closed