When creating a field as seen below (DummyCharField), a new migration only
gets created if `kwargs['max_length'] = 255` is wrapped inside an `if`.
{{{#!python
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.)
--
Ticket URL: <https://code.djangoproject.com/ticket/30527>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
* version: 2.2 => master
* component: Core (Management commands) => Migrations
Comment:
You're use case is described in
[https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/#writing-
custom-model-fields Writing custom model fields documentation]. It seems
that [https://docs.djangoproject.com/en/2.2/howto/custom-model-fields
/#field-deconstruction deconstruct()] is missing which is very important
for migrations.
Closing per TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/30527#comment:1>
* status: closed => new
* resolution: invalid =>
Comment:
I tried out `deconstruct()`, but still had the same problem. (also see
[https://stackoverflow.com/questions/56422003/no-new-migration-for-
subclass-of-subclass-of-a-field Stackoverflow])
(also tried `deconstruct()` in the parent-field)
--
Ticket URL: <https://code.djangoproject.com/ticket/30527#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
This is still not a support channel. See
TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/30527#comment:3>