3

I tried to install Django Panels and ran into an error. I installed using pip -- pip install django-debug-toolbar -- and it seemed to go alright. But when I added it to my project like this:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.flatpages',
    'coltrane',
    'markdown',
    'debug_toolbar',
)

and then ran python manage.py syncdb got the following error:

python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.7.dev20140121103749-py2.7.egg/django/core/management/__init__.py", line 427, in execute_from_command_line
    utility.execute()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.7.dev20140121103749-py2.7.egg/django/core/management/__init__.py", line 391, in execute
    django.setup()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.7.dev20140121103749-py2.7.egg/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.7.dev20140121103749-py2.7.egg/django/apps/registry.py", line 105, in populate
    app_config.import_models(all_models)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.7.dev20140121103749-py2.7.egg/django/apps/base.py", line 160, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/debug_toolbar/models.py", line 10, in <module>
    from debug_toolbar.middleware import DebugToolbarMiddleware
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/debug_toolbar/middleware.py", line 13, in <module>
    from debug_toolbar.toolbar import DebugToolbar
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 153, in <module>
    urlpatterns = DebugToolbar.get_urls()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 147, in get_urls
    for panel_class in cls.get_panel_classes():
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/debug_toolbar/toolbar.py", line 125, in get_panel_classes
    (panel_module, e))
django.core.exceptions.ImproperlyConfigured: Error importing debug panel debug_toolbar.panels.signals: "cannot import name WEAKREF_TYPES"

I've searched around for answers to this but with no luck. Does anyone know what might be wrong here? Any help would be greatly appreciated.

fraxture
  • 5,113
  • 4
  • 43
  • 83

3 Answers3

10

The problem is specifically with the signals debug panel. Apparently Django 1.7 incorporates a lot of changes to the signals library that are specifically incompatible with the debug toolbar.

You can run DDT on Django 1.7 if you disable the panel. Easy enough to do with a change to your settings.py:

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.cache.CacheDebugPanel',
    #'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logger.LoggingPanel',
    'debug_toolbar.panels.profiling.ProfilingDebugPanel',
]

If you need signal inspection, you can backport WEAKREF_TYPES from Django 1.6 django.dispatch.dispatcher into your environment and update debug_toolbar.panels.signals with the appropriate dependencies. This took me about ten minutes, but I threw that solution away when I discovered I could just disable the problem panel.

Condiment
  • 180
  • 4
2

As commented in the issue, the issue with debug toolbar on Django 1.7 seems to be resolved in version 1.1 and up of django-debug-toolbar (tested 1.1 and 1.2.1 myself).

Please try upgrading and see if the issue resolves itself

tutuDajuju
  • 10,307
  • 6
  • 65
  • 88
0

You are using a development version of django Django-1.7.dev20140121103749, which is only for testing and not for production use. This is why the import is not working.

You need to use the latest release version of django, which is 1.6.1

Please download the correct version.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • 5
    Unfortunately, Django 1.7 is out now and this error still persists. I [filed a bug](https://github.com/django-debug-toolbar/django-debug-toolbar/issues/632) for what it's worth. – Nathan Osman Sep 03 '14 at 04:21