django调试工具栏打破了管理员? [英] django debug toolbar broke the admin?

查看:254
本文介绍了django调试工具栏打破了管理员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试项目,我在开发应用程序之前,我始终安装和测试包。由于我安装了django调试工具栏,因此当连接到管理员网站时,我收到以下错误消息


$ b $对于'app_list'与参数'()'和关键字参数'{'app_label':'auth'}'没有找到相反,b

  NoReverseMatch在/ admin / 
。 0模式尝试:[]
请求方法:GET
请求URL:http://127.0.0.1:8000/admin/
Django版本:1.8
异常类型:NoReverseMatch
异常值:
反向'app_list'与参数'()'和关键字参数'{'app_label':'auth'}'未找到。 0模式尝试:[]
异常位置:C:\Anaconda\lib\site-packages\django-1.8-py2.7.egg\django\core\urlresolvers。 py在_reverse_with_prefix中,行436
Python可执行文件:C:\Anaconda\python.exe
Python版本:2.7.6
Python路径:
['C:\ \Users\\ut1u3h\\\\test_project',
'C:\\\Anaconda\\\\lib\\site-packages\\django-1.8-py2.7 .egg',
'C:\\Anaconda\\lib\\site-packages-\\\django_rosetta-0.7.5-py2.7.egg',
' C:\\Anaconda\\\\\\\site-packages\\django_debug_toolbar-1.1-py2.7.egg',
'C:\\Anaconda\\\ lib \\\\\\\\\\\\,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 'C:\\Anaconda\\DLLs',
'C:\\Anaconda\\lib' ,
'C:\\\Anaconda\\lib\\\\plat-win',
'C:\\Anaconda\\lib\\lib- tk',
'C:\\Anaconda',
'c:\\anaconda\\lib\\\\site-packages\\setuptools-2.2-py2 .7.egg',
'C:\\Anaconda\\lib\\site-包',
'C:\\Anaconda\\lib\\ \\\site- packages\\PIL',
'C:\\Anaconda\\lib\\site-packages\\\\\\\\\\\ :\\Anaconda\\lib\\site-packages\\\\\\lib',
'C:\\Anaconda\\lib\\\ \\ site-packages\\Pythonwin']
服务器时间:Fri,25 Apr 2014 10:13:32 +0000

这是我的 settings.py 文件

  
用于test_project项目的Django设置。

有关此文件的更多信息,请参阅
https://docs.djangoproject.com/en/dev/topics/settings/

有关完整列表的设置及其值,请参阅
https://docs.djangoproject.com/en/dev/ref/settings/


#在项目中构建路径像这样:os.path.join(BASE_DIR,...)
import os
BASE_DIR = os.path.dirname(__ file__)


#启动开发设置 - 不适合生产
#请参阅https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

#安全警告:不要运行调试开始在生产!
DEBUG = True
ALLOWED_HOSTS = ['localhost','127.0.0.1']
TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['* ']
TEMPLATE_DIRS = [os.path.join(BASE_DIR,'templates')]

#应用程序定义

INSTALLED_APPS =(

'debug_toolbar',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls ',
'rosetta',


MIDDLEWARE_CLASSES =(
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware .locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware'
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',


ROOT_URLCONF ='test_project.urls'

WSGI_APPLICATION ='test_project.wsgi.application'


#数据库
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
'default':{
'ENGINE':'django .db.backends.sqlite3',
'NAME':os.path.join(BASE_DIR,'db.sqlite3'),
}
}

#国际化
#https://docs.djangoproject.com/en/dev/topics/i18n/

LANGUAGE_CODE ='en-us'

LANGUAGES =(
('fr','French'),
('en-us','English'),


TIME_ZONE ='UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True
LOCALE_PATHS =(os.path.join(BASE_DIR,'../ locale /'))

ROSETTA_STORAGE_CLASS ='rosetta.storage.CacheRosettaStorage'

#静态文件(CSS,JavaScript,图像)
#https:// docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL ='/ static /'
SITE_ROOT = os.path.dirname(os.path.realpath(__ file__ ))
STATICFILES_DIRS =(
os.path.join(SITE_ROOT,'static /'),


TEMPLATE_CONTEXT_PROCESSORS =(
django.core.context_processors.debug,
django
django.core.context_processors.media
django.contrib.auth.context_processors.auth)

DEBUG_TOOLBAR_​​PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels。 headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging。 LoggingPanel',
'debug_toolbar.panels.redirects.Redir ectsPanel',
]

INTERNAL_IPS =('127.0.0.1',)

和我的 urls.py 如下所示:

  urlpatterns = patterns(' ',
#示例:
#url(r'^ $','test_project.views.home',name ='home'),
#url(r'^ blog /' ,include('blog.urls')),

url(r'^ admin /',include(admin.site.urls)),
url(r'^ rosetta /' ,include('rosetta.urls')),


urlpatterns + = i18n_patterns('',url(r'^ $',views.home),)


解决方案

如django-debug-toolbar README [1]所述, Django支持1.7,根据你的帖子你正在使用Django 1.8,这是早期的开发和不稳定的。简单的降级应该可以解决问题。



[1] https://github.com/django-debug-toolbar/django-debug-toolbar


I have a little test project on which I always install and test package prior to my dev apps. Since I installed the django debug toolbar on it, I'm having the following error message when connecting to the admin site ( the other urls are fine ):

NoReverseMatch at /admin/
Reverse for 'app_list' with arguments '()' and keyword arguments '{'app_label': 'auth'}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version: 1.8
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'app_list' with arguments '()' and keyword arguments '{'app_label': 'auth'}' not found. 0 pattern(s) tried: []
Exception Location: C:\Anaconda\lib\site-packages\django-1.8-py2.7.egg\django\core\urlresolvers.py in _reverse_with_prefix, line 436
Python Executable:  C:\Anaconda\python.exe
Python Version: 2.7.6
Python Path:    
['C:\\Users\\ut1u3h\\test_project',
 'C:\\Anaconda\\lib\\site-packages\\django-1.8-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages\\django_rosetta-0.7.5-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages\\django_debug_toolbar-1.1-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages\\sqlparse-0.1.11-py2.7.egg',
 'C:\\Anaconda\\python27.zip',
 'C:\\Anaconda\\DLLs',
 'C:\\Anaconda\\lib',
 'C:\\Anaconda\\lib\\plat-win',
 'C:\\Anaconda\\lib\\lib-tk',
 'C:\\Anaconda',
 'c:\\anaconda\\lib\\site-packages\\setuptools-2.2-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages',
 'C:\\Anaconda\\lib\\site-packages\\PIL',
 'C:\\Anaconda\\lib\\site-packages\\win32',
 'C:\\Anaconda\\lib\\site-packages\\win32\\lib',
 'C:\\Anaconda\\lib\\site-packages\\Pythonwin']
Server time:    Fri, 25 Apr 2014 10:13:32 +0000

this is my settings.py file

"""
Django settings for test_project project.

For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(__file__)


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['*']
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

# Application definition

INSTALLED_APPS = (

    'debug_toolbar',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',
    'rosetta',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'test_project.urls'

WSGI_APPLICATION = 'test_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/

LANGUAGE_CODE = 'en-us'

LANGUAGES = (
    ('fr', 'French'),
    ('en-us', 'English'),
)

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True
LOCALE_PATHS = (os.path.join(BASE_DIR, '../locale/'),)

ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)

TEMPLATE_CONTEXT_PROCESSORS = ( 
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.contrib.auth.context_processors.auth" )

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
]

INTERNAL_IPS = ('127.0.0.1',)

and my urls.py looks like this:

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'test_project.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^rosetta/', include('rosetta.urls')),

)
urlpatterns += i18n_patterns('', url(r'^$', views.home),)

解决方案

As stated in the django-debug-toolbar README [1], only Django up to 1.7 is supported; according to your post you are using Django 1.8, which is in early development and unstable. Simple downgrading should solve the issue.

[1] https://github.com/django-debug-toolbar/django-debug-toolbar

这篇关于django调试工具栏打破了管理员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆