Opened 7 years ago
Closed 7 years ago
#29378 closed Bug (worksforme)
migration does not consistently rename field "id" to "model_id" depending on model name
Reported by: | Shadi Akiki | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 2.0 |
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
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.
Change History (2)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Component: | Uncategorized → Migrations |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Type: | Uncategorized → Bug |
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)
Note:
See TracTickets
for help on using tickets.
Can you confirm the issue still happens if you remove
serialize
andprimary_key
? These flags shouldn't be when declaring a PK explicitly.