[Django] #30527: Problem with creating migrations for subclassed field changes

7 views
Skip to first unread message

Django

unread,
May 29, 2019, 5:49:13 AM5/29/19
to django-...@googlegroups.com
#30527: Problem with creating migrations for subclassed field changes
-------------------------------------+-------------------------------------
Reporter: wfehr | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 2.2
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`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`.

{{{#!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.

Django

unread,
May 30, 2019, 2:22:27 AM5/30/19
to django-...@googlegroups.com
#30527: Problem with creating migrations for subclassed field changes.
-------------------------------+--------------------------------------
Reporter: Wolfgang Fehr | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by felixxm):

* 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>

Django

unread,
Jun 14, 2019, 7:30:22 AM6/14/19
to django-...@googlegroups.com
#30527: Problem with creating migrations for subclassed field changes.
-------------------------------+--------------------------------------
Reporter: Wolfgang Fehr | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Wolfgang Fehr):

* 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>

Django

unread,
Jun 14, 2019, 8:05:14 AM6/14/19
to django-...@googlegroups.com
#30527: Problem with creating migrations for subclassed field changes.
-------------------------------+--------------------------------------
Reporter: Wolfgang Fehr | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* 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>

Reply all
Reply to author
Forward
0 new messages