Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#24620 closed Bug (worksforme)

showmigrations broken in Django 1.8

Reported by: Miguel Araujo Owned by: nobody
Component: Core (Management commands) Version: 1.8
Severity: Normal Keywords: showmigrations
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


After upgrading to Django 1.8 and running python showmigrations it breaks with the following stack trace:

Traceback (most recent call last):
  File "", line 20, in <module>
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/core/management/", line 338, in execute_from_command_line
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/core/management/", line 330, in execute
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/core/management/", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/core/management/", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/core/management/commands/", line 32, in handle
    connection = connections[db]
  File "/Users/map/.virtualenvs/odin/lib/python2.7/site-packages/django/db/", 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.

Change History (5)

comment:1 Changed 7 years ago by Tim Graham

Easy pickings: unset
Has patch: unset

I can't reproduce this using the tutorial project.

comment:2 Changed 7 years ago by Tim Graham

Resolution: worksforme
Status: newclosed

comment:3 Changed 7 years ago by Miguel Araujo


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:

Sorry for the false positive.


comment:4 Changed 7 years ago by Miguel Araujo

I've been reading some of the commits that moved from optparse to argparse Django's command system:

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:

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.

comment:5 Changed 7 years ago by Miguel Araujo

Seems last commit of django-configurations has this already handled:

Last edited 7 years ago by Miguel Araujo (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top