[Django] #24620: showmigrations broken in Django 1.8

10 views
Skip to first unread message

Django

unread,
Apr 10, 2015, 8:32:17 AM4/10/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
--------------------------------------------+----------------------------
Reporter: maraujop | Owner: nobody
Type: Bug | Status: new
Component: Core (Management commands) | Version: 1.8
Severity: Normal | Keywords: showmigrations
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
--------------------------------------------+----------------------------
After upgrading to Django 1.8 and running `python manage.py
showmigrations` it breaks with the following stack trace:

{{{
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/core/management/commands/showmigrations.py", line 32, in
handle
connection = connections[db]
File "/Users/map/.virtualenvs/odin/lib/python2.7/site-
packages/django/db/utils.py", line 234, in __getitem__
if hasattr(self._connections, alias):
TypeError: hasattr(): attribute name must be string
}}}

This can be fixed adding `use_argparse = True` to show migrations command
class, so that add_arguments gets executed settting defaults. This way you
get the expected response.

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

Django

unread,
Apr 10, 2015, 9:22:46 AM4/10/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
-------------------------------------+-------------------------------------

Reporter: maraujop | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:

Keywords: showmigrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* has_patch: 1 => 0
* easy: 1 => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I can't reproduce this using the tutorial project.

--
Ticket URL: <https://code.djangoproject.com/ticket/24620#comment:1>

Django

unread,
Apr 11, 2015, 8:52:28 AM4/11/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
-------------------------------------+-------------------------------------
Reporter: maraujop | Owner: nobody
Type: Bug | Status: closed

Component: Core (Management | Version: 1.8
commands) | Resolution:
Severity: Normal | worksforme

Keywords: showmigrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


--
Ticket URL: <https://code.djangoproject.com/ticket/24620#comment:2>

Django

unread,
Apr 13, 2015, 6:12:34 AM4/13/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
-------------------------------------+-------------------------------------
Reporter: maraujop | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) | Resolution:
Severity: Normal | worksforme
Keywords: showmigrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by maraujop):

Ok,

Seems to be an issue with django-configurations which sets a
`self.option_list` making `use_argparse = True` and then turning the
property False and not calling `add_arguments`.

Related to this:
https://github.com/jezdez/django-configurations/issues/109

Sorry for the false positive.

Miguel

--
Ticket URL: <https://code.djangoproject.com/ticket/24620#comment:3>

Django

unread,
Apr 13, 2015, 7:06:48 AM4/13/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
-------------------------------------+-------------------------------------
Reporter: maraujop | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) | Resolution:
Severity: Normal | worksforme
Keywords: showmigrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by maraujop):

I've been reading some of the commits that moved from optparse to argparse
Django's command system:
https://github.com/django/django/commit/856863860352aa1f0288e6c9168a0e423c4f5184
https://github.com/django/django/commit/f17b24e407385eb18651bf023a187347aa9c1f75

To be honest if `option_list` has been replaced by `add_arguments`
method. And in
`BaseCommand` `add_arguments` is called only for new system as you can see
here:
https://github.com/django/django/blob/0ed7d155635da9f79d4dd67e4889087d3673c6da/django/core/management/base.py#L308

This change is in reality backwards incompatible (which is not Django's
usual philosophy), although the door stays open for still being backwards
compatible, but it implies author's work. In my understanding usually
Django gives a time gap to adjust apps in situations like this.

As django-configurations is still using optparse and is injecting an
option for all commands, which sets the right configuration to use. It is
breaking all Django commands.

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

Django

unread,
Apr 13, 2015, 7:54:07 AM4/13/15
to django-...@googlegroups.com
#24620: showmigrations broken in Django 1.8
-------------------------------------+-------------------------------------
Reporter: maraujop | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) | Resolution:
Severity: Normal | worksforme
Keywords: showmigrations | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by maraujop):

Seem last commit of django-configurations has this handled already:
https://github.com/jezdez/django-
configurations/blob/master/configurations/importer.py#L37

--
Ticket URL: <https://code.djangoproject.com/ticket/24620#comment:5>

Reply all
Reply to author
Forward
0 new messages