Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25384 closed Cleanup/optimization (fixed)

New Migrations Generated with Improperly Sorted Imports

Reported by: jambonrose Owned by: nobody
Component: Migrations Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Markus Holtermann)

New migration files are generated with the following line of code (found in the django/db/migrations/writer.py file):

    from django.db import models, migrations

Anytime isort is run on a migration file (for example, for data migrations), it will reorder the import to:

    from django.db import migrations, models

It would be great if we were generating properly sorted documents.

Change History (9)

comment:1 by Maxime Lorant, 9 years ago

Description: modified (diff)

comment:2 by Collin Anderson, 9 years ago

Hi, could you try this out on master (1.9)? I think it _may_ have been fixed already.

comment:3 by jambonrose, 9 years ago

Argh. Collin is right. I was looking at this on the wrong branch. Very sorry.

comment:4 by jambonrose, 9 years ago

Resolution: invalid
Status: newclosed

comment:5 by Tim Graham, 9 years ago

Resolution: invalidduplicate

(done in #24155)

comment:6 by Markus Holtermann, 9 years ago

Resolution: duplicate
Status: closednew
Triage Stage: UnreviewedAccepted

As briefly discussed on IRC the other day, I add a patch for 1.8 to change the order of those two imports. It's annoying to change the order manually.

The issue is indeed fixed on master.

comment:7 by Markus Holtermann, 9 years ago

Description: modified (diff)
Has patch: set

comment:8 by Markus Holtermann <info@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 3cc5cc79:

[1.8.x] Fixed #25384 -- Ordered imports in newly created migration files

comment:9 by Markus Holtermann <info@…>, 9 years ago

In 84b0a8d:

Fixed #25384 -- Ordered imports in newly created migration files

Partial forwardport of 3cc5cc79584b66dafac54264d072ac1206426471 from
stable/1.8.x as the issue was already fixed in master in
a7bc00e17bebe34cdf23f744937b3c386ee73d81

Note: See TracTickets for help on using tickets.
Back to Top