#22577 closed Bug (fixed)
The makemigrations management command has a problem with migrations dir
Reported by: | Owned by: | Vidir Valberg Gudmundsson | |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Release blocker | Keywords: | makemigrations, fail, init, file |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When the migration folder does not have an init
http://codepad.org/U2nGptor
File "/home/archie/git/django/django/db/migrations/writer.py", line 150, in path basedir = os.path.dirname(migrations_module.__file__) AttributeError: 'module' object has no attribute '__file__'
the problem lies with makemigrations.py
line 134-36 they are checking to see if an init file exists in the migrations dir but it checks using a line that depends on the existence of __init__.py
. line 130 , writer.path
, following to see where this code comes from led me to line 149 and 150 which need there to be an init file for __file__
to be an attribute there ..
tl;dr
makemigrations
checks for an init file using os.path.isdir
but with a call that depends on an __init__.py
for it treats it as a module before it knows if it is a module
Change History (14)
comment:2 by , 11 years ago
Description: | modified (diff) |
---|
comment:3 by , 11 years ago
comment:4 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:5 by , 11 years ago
I got this problem for some unknown reason. I resolved it by deleting the migrations folder and running makemigrations again
comment:6 by , 11 years ago
I got this problem too. Could it because I'm on Python 3.
Delete the migrations folder, solve the problem.
comment:7 by , 11 years ago
I got this because I'd created a new migrations folder, but forgot to make it a Python package (no __init__.py
) while I was migrating an app from South.
comment:8 by , 11 years ago
Ran in to this problem today on 1.7b4 and python 3.3. Same result on python 3.4.1.
The "makemigrations" command fails if the migrations folder is empty. It succeeds as soon as I created init.py in the folder. See this gist:
comment:9 by , 11 years ago
Resolution: | needsinfo |
---|---|
Severity: | Normal → Release blocker |
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
comment:10 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I created an app with an empty migrations folder and ran
makemigrations
, but did not get an error.Could you clarify the steps to reproduce?