[Django] #29378: migration does not consistently rename field "id" to "model_id" depending on model name

9 views
Skip to first unread message

Django

unread,
May 3, 2018, 8:09:28 AM5/3/18
to django-...@googlegroups.com
#29378: migration does not consistently rename field "id" to "model_id" depending
on model name
-----------------------------------------+------------------------
Reporter: Shadi Akiki | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
In the case where the model is

{{{
class Something(models.Model):
field1 = ...
field2 = ...
}}}

adding a field

{{{
something_id = models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)^M
}}}

generates a "rename" in the migration from "id" to "something_id".

However, for

{{{
class MyModel(models.Model):
field1 = ...
field2 = ...
}}}

adding a field

{{{
mymodel_id = models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)^M
}}}

does not generate a "rename" in the migration.

--
Ticket URL: <https://code.djangoproject.com/ticket/29378>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 3, 2018, 12:41:03 PM5/3/18
to django-...@googlegroups.com
#29378: migration does not consistently rename field "id" to "model_id" depending
on model name
-------------------------------+--------------------------------------

Reporter: Shadi Akiki | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
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
-------------------------------+--------------------------------------

Comment (by Simon Charette):

Can you confirm the issue still happens if you remove `serialize` and
`primary_key`? These flags shouldn't be when declaring a PK explicitly.

--
Ticket URL: <https://code.djangoproject.com/ticket/29378#comment:1>

Django

unread,
May 4, 2018, 10:06:02 AM5/4/18
to django-...@googlegroups.com
#29378: migration does not consistently rename field "id" to "model_id" depending
on model name
-----------------------------+--------------------------------------

Reporter: Shadi Akiki | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 2.0
Severity: Normal | Resolution: worksforme

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 Tim Graham):

* status: new => closed
* resolution: => worksforme
* component: Uncategorized => Migrations
* type: Uncategorized => Bug


Comment:

I'm not able to reproduce:
{{{
$ python manage.py makemigrations
Did you rename mymodel.id to mymodel.mymodel_id (a AutoField)? [y/N]
}}}
The model:
{{{
class MyModel(models.Model):


mymodel_id = models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29378#comment:2>

Reply all
Reply to author
Forward
0 new messages