我有一个小测试项目,我总是在我的开发应用程序之前安装和测试包.由于我在其上安装了django调试工具栏,因此在连接到管理站点时出现以下错误消息(其他网址很好):
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
这是我的settings.py文件
""" 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',)
而我的urls.py看起来像这样:
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),)
Daniel Hawki.. 5
正如Luca所指出的,这可能是由于您的INSTALLED_APPS
设置排序不正确造成的. 'debug_toolbar.apps.DebugToolbarConfig'
必须追求 'django.contrib.staticfiles'
,如文档中所示.
正如Luca所指出的,这可能是由于您的INSTALLED_APPS
设置排序不正确造成的. 'debug_toolbar.apps.DebugToolbarConfig'
必须追求 'django.contrib.staticfiles'
,如文档中所示.