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 comees from led me to line149 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
--
Ticket URL: <https://code.djangoproject.com/ticket/22577>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
It is dot org not dot com
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:1>
Old description:
> When the migration folder does not have an init
> http://codepad.com/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 comees from led me to
> line149 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
New description:
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
--
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:2>
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I created an app with an empty migrations folder and ran `makemigrations`,
but did not get an error.
{{{
$ mkdir polls/migrations
$ python manage.py makemigrations polls
Migrations for 'polls':
0001_initial.py:
- Create model Poll
- Create model Choice
}}}
Could you clarify the steps to reproduce?
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:3>
* status: new => closed
* resolution: => needsinfo
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:4>
Comment (by nielsen.ruben@…):
I got this problem for some unknown reason. I resolved it by deleting the
migrations folder and running makemigrations again
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:5>
Comment (by anonymous):
I got this problem too. Could it because I'm on Python 3.
Delete the migrations folder, solve the problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:6>
Comment (by david@…):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:7>
Comment (by anonymous):
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:
https://gist.github.com/timster/c87117f221690a2dbc72
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:8>
* status: closed => new
* resolution: needsinfo =>
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:9>
* status: new => assigned
* owner: nobody => valberg
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:10>
* status: new => assigned
* owner: nobody => valberg
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:11>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/2824
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3a6cb9f497af4e5eb8351706056eae50a4ed3c45"]:
{{{
#!CommitTicketReference repository=""
revision="3a6cb9f497af4e5eb8351706056eae50a4ed3c45"
Fixed #22577: Python 3 broke on non-module migrations directory
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:13>
Comment (by Andrew Godwin <andrew@…>):
In [changeset:"66a99fa21076529a5e71996a8862597284403727"]:
{{{
#!CommitTicketReference repository=""
revision="66a99fa21076529a5e71996a8862597284403727"
Merge pull request #2824 from valberg/22577
Fixed #22577: Python 3 broke on non-module migrations directory
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:14>
Comment (by Andrew Godwin <andrew@…>):
In [changeset:"7f0c207d1b33b03b5bfe89c0e09d4f790c8a1d0a"]:
{{{
#!CommitTicketReference repository=""
revision="7f0c207d1b33b03b5bfe89c0e09d4f790c8a1d0a"
[1.7.x] Fixed #22577: Python 3 broke on non-module migrations directory
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:15>