Opened 5 years ago

Closed 5 years ago

Last modified 5 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 Changed 5 years ago by Maxime Lorant

Description: modified (diff)

comment:2 Changed 5 years ago by Collin Anderson

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

comment:3 Changed 5 years ago by jambonrose

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

comment:4 Changed 5 years ago by jambonrose

Resolution: invalid
Status: newclosed

comment:5 Changed 5 years ago by Tim Graham

Resolution: invalidduplicate

(done in #24155)

comment:6 Changed 5 years ago by Markus Holtermann

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 Changed 5 years ago by Markus Holtermann

Description: modified (diff)
Has patch: set

comment:8 Changed 5 years ago by Markus Holtermann <info@…>

Resolution: fixed
Status: newclosed

In 3cc5cc79:

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

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

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