#19688 closed Bug (fixed)
It's not possible to use `six.with_metaclass` to subclass `models.Model` with a custom metaclass.
Reported by: | Simon Charette | Owned by: | Simon Charette |
---|---|---|---|
Component: | Python 3 | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A couple of django apps in the wild subclass models.base.BaseModel
in order to provide some extra functionality.
If those apps are ever ported to support PY2 and PY3 in the same code base using six they will have to use six.with_metaclass
to achieve it.
Unfortunately, models.base.BaseModel.__new__
chokes when a model is defined this way:
from django.db import models from django.utils import six class CustomBaseModel(models.base.BaseModel): pass class CustomModel(six.with_metaclass(CustomBaseModel, models.Model)): pass
because the 'NewBase
' checks don't take into account this case.
Attachments (1)
Change History (8)
comment:1 Changed 11 years ago by
Owner: | changed from nobody to Simon Charette |
---|---|
Status: | new → assigned |
Changed 11 years ago by
Attachment: | 0001-Fixed-19688-Allow-model-subclassing-with-a-custom-me.patch added |
---|
comment:2 Changed 11 years ago by
Has patch: | set |
---|
comment:3 Changed 11 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
All tests pass on Python 2.7.3 SQLite.