django-extensions / django-extensions

This is a repository for collecting global custom management extensions for the Django Framework.
https://django-extensions.readthedocs.io
MIT License
6.53k stars 1.15k forks source link

show_urls raising AttributeError #508

Closed jpadilla closed 10 years ago

jpadilla commented 10 years ago

Tested on Python 3.3 and Django 1.6.5.

Traceback (most recent call last):
  File "./manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/jpadilla/.virtualenvs/boards-backend-3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/jpadilla/.virtualenvs/boards-backend-3.3/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/jpadilla/.virtualenvs/boards-backend-3.3/lib/python3.3/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/jpadilla/.virtualenvs/boards-backend-3.3/lib/python3.3/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Users/jpadilla/.virtualenvs/boards-backend-3.3/lib/python3.3/site-packages/django_extensions/management/commands/show_urls.py", line 111, in handle
    'decorator': decorator if decorator in func.func_globals else '',
AttributeError: 'function' object has no attribute 'func_globals'
trbs commented 10 years ago

Thanks for the report.

func_globals is indeed gone in Python3.

This is fixed in the development version of django_extensions.

trbs commented 10 years ago

I have uploaded version 1.3.7 which includes the fix for this issue.

neara commented 10 years ago

I am using version 1.3.7 and i get same error.

Python 2.7.5, Django 1.6.5

Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django_extensions/management/commands/show_urls.py", line 107, in handle func_globals = func.__globals__ if six.PY3 else func.func_globals AttributeError: 'ArenaWrapper' object has no attribute 'func_globals'

trbs commented 10 years ago

Please try with changeset 8f262a4 on master.

neara commented 10 years ago

This is what i've got with the changeset:

Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/Users/anatr/Projects/FanWaze/ArenaWaze/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/Users/usr/Projects/Arena/lib/python2.7/site-packages/django_extensions/management/commands/show_urls.py", line 98, in handle raise Exception("Format style '%s' does not exist. Options: %s" % (format_style, FMTR.keys())) Exception: Format style 'None' does not exist. Options: ['dense', 'verbose']

options at line 96:

{'language': None, 'settings': None, 'pythonpath': None, 'verbosity': u'1', 'traceback': None, 'format_style': None, 'unsorted': None, 'decorator': None}

Changing line 96 from format_style = options.get('format_style', 'dense') to format_style = options.get('format_style', 'dense') or 'dense' did the trick.

trbs commented 10 years ago

Thanks for the feedback, per d8ef952 we also check explicitly for None and if so set the default. Could you check again with this commit please ?

If this works then I can do a new release so you can update any requirements you might have.

neara commented 10 years ago

works like a charm ;) ty

trbs commented 10 years ago

Thanks for reporting and testing!

neara commented 10 years ago

ty for addressing this issue so fast!