Opened 6 years ago
Closed 6 years ago
#30527 closed Bug (invalid)
Problem with creating migrations for subclassed field changes.
Reported by: | Wolfgang Fehr | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
makemigrations
gives out 'No changes detected' for changes on a sub-subclass of CharField (only tested with this field).
When creating a field as seen below (DummyCharField), a new migration only gets created if kwargs['max_length'] = 255
is wrapped inside an if
.
class BaseDummyCharField(models.CharField): def __init__(self, *args, **kwargs): if 'max_length' not in kwargs: kwargs['max_length'] = 64 super().__init__(*args, **kwargs) class DummyCharField(BaseDummyCharField): def __init__(self, *args, **kwargs): # Without the if 'makemigrations' does not recognize changes. # Previous max_length (in initial migration) is 64. if 'max_length' not in kwargs: kwargs['max_length'] = 255 super().__init__(*args, **kwargs) class DummyModel(models.Model): dummy = DummyCharField()
(Also reproducable in version 2.0.6, maybe others as well.)
Change History (3)
comment:1 by , 6 years ago
Component: | Core (Management commands) → Migrations |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Summary: | Problem with creating migrations for subclassed field changes → Problem with creating migrations for subclassed field changes. |
Version: | 2.2 → master |
comment:2 by , 6 years ago
Resolution: | invalid |
---|---|
Status: | closed → new |
I tried out deconstruct()
, but still had the same problem. (also see Stackoverflow)
(also tried deconstruct()
in the parent-field)
comment:3 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is still not a support channel. See TicketClosingReasons/UseSupportChannels.
You're use case is described in Writing custom model fields documentation. It seems that deconstruct() is missing which is very important for migrations.
Closing per TicketClosingReasons/UseSupportChannels.