[Django] #22577: The makemigrations management command has a problem with migrations dir

48 views
Skip to first unread message

Django

unread,
May 5, 2014, 7:01:14 AM5/5/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
----------------------------+----------------------------------------------
Reporter: | Owner: nobody
japrogramer@… | Status: new
Type: Bug | Version: master
Component: Migrations | Keywords: makemigrations, fail, init, file
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 0 |
----------------------------+----------------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/22577>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 5, 2014, 7:09:20 AM5/5/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anonymous):

* 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>

Django

unread,
May 5, 2014, 7:18:28 AM5/5/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by timo:

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>

Django

unread,
May 5, 2014, 12:16:55 PM5/5/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* 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>

Django

unread,
May 7, 2014, 8:30:02 AM5/7/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo

Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => needsinfo


--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:4>

Django

unread,
Jun 3, 2014, 3:11:52 AM6/3/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 8, 2014, 1:59:39 AM6/8/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 11, 2014, 7:34:56 AM6/11/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 17, 2014, 9:50:35 AM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: makemigrations, | Triage Stage:
fail, init, file | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 17, 2014, 10:10:14 AM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* status: closed => new
* resolution: needsinfo =>
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:9>

Django

unread,
Jun 17, 2014, 11:41:44 AM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: assigned

Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by valberg):

* status: new => assigned
* owner: nobody => valberg


--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:10>

Django

unread,
Jun 17, 2014, 11:42:52 AM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by valberg):

* status: new => assigned
* owner: nobody => valberg


--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:11>

Django

unread,
Jun 17, 2014, 11:51:54 AM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by valberg):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/2824

--
Ticket URL: <https://code.djangoproject.com/ticket/22577#comment:12>

Django

unread,
Jun 17, 2014, 12:54:57 PM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: fixed

Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Víðir Valberg Guðmundsson <valberg@…>):

* 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>

Django

unread,
Jun 17, 2014, 12:54:59 PM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: fixed
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 17, 2014, 12:58:10 PM6/17/14
to django-...@googlegroups.com
#22577: The makemigrations management command has a problem with migrations dir
-------------------------------------+-------------------------------------
Reporter: japrogramer@… | Owner: valberg
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: fixed
Keywords: makemigrations, | Triage Stage: Accepted
fail, init, file | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages