我正在阅读一个名为“编写第一个Django应用程序”的官方Django教程,目前在第2部分。这是URL:https://docs.djangoproject.com/en/2.2/intro/tutorial02/
当按照说明尝试访问位于http://127.0.0.1:8000/admin/的管理面板时,出现以下错误:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 2.2.4
Python Version: 3.7.3
Installed Applications:
['polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py" in wrapper
241. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner
213. if request.path == reverse('admin:logout', current_app=self.name):
File "/usr/local/lib/python3.7/site-packages/django/urls/base.py" in reverse
58. app_list = resolver.app_dict[ns]
File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py" in app_dict
512. self._populate()
File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py" in _populate
463. url_pattern._populate()
File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py" in _populate
446. for url_pattern in reversed(self.url_patterns):
Exception Type: TypeError at /admin/
Exception Value: 'set' object is not reversible
我在装有Python 3的Mac上。我查找了所有其他类似问题以查找此错误,但我的代码似乎是正确的,所以那里的答案都没有让我高兴
这是我的urls.py代码
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('polls/', include('polls.urls'))
]
这是settings.py中的应用列表
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
您知道这里可能出什么问题吗?