Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29091 closed Bug (fixed)

makemigrations crashes if a migration directory doesn't have an __init__.py

Reported by: Rafael Lott Owned by: nobody
Component: Migrations Version: 2.0
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I upgraded from Django 1.11 to Django 2.0.

When I ran 'makemigrations', I got this error.

   File "/home/webapp/.virtualenvs/odin/lib/python3.5/site-packages/django/db/migrations/questioner.py", line 51, in ask_initial
    filenames = os.listdir(migrations_module.__path__[0])
TypeError: '_NamespacePath' object does not support indexing

I manage to fix it by editing the file 'django/db/migrations/questioner.py' line 51 from:

filenames = os.listdir(migrations_module.__path__[0])

to

filenames = os.listdir(list(migrations_module.__path__)[0])

I don't know if this is the correct solution.

Change History (4)

comment:1 by Tim Graham, 6 years ago

Severity: NormalRelease blocker
Summary: Error on makemigrations: '_NamespacePath' object does not support indexingmakemigrations crashes if a migration directory doesn't have an __init__.py
Triage Stage: UnreviewedAccepted

At least one of your migrations directories doesn't have an __init__.py file. This is a regression in aadd3aeb2ba3153e35bd805c80c901f289a6f333 and a recurrence of #21868 (which was committed without a test).

comment:2 by Tim Graham, 6 years ago

Has patch: set

comment:3 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: newclosed

In 0a37ea56:

Fixed #29091 -- Fixed makemigrations crash if migrations directory doesn't have init.py.

Regression in aadd3aeb2ba3153e35bd805c80c901f289a6f333.

comment:4 by Tim Graham <timograham@…>, 6 years ago

In 834843ca:

[2.0.x] Fixed #29091 -- Fixed makemigrations crash if migrations directory doesn't have init.py.

Regression in aadd3aeb2ba3153e35bd805c80c901f289a6f333.

Backport of 0a37ea56d05208e31ed2f29fdffca65b6d92fa2e from master

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