Django Tutorial, Getting: Type Error at / admin / argument for reverse () should be a sequence

I am working on a django tutorial for version 1.8 and I get an error message that I am stuck and cannot understand. I thought I was following T. carefully.

I have the following tree installed:

. β”œβ”€β”€ dj_project β”‚ β”œβ”€β”€ __init__.py β”‚ β”œβ”€β”€ __init__.pyc β”‚ β”œβ”€β”€ settings.py β”‚ β”œβ”€β”€ settings.pyc β”‚ β”œβ”€β”€ urls.py β”‚ β”œβ”€β”€ urls.pyc β”‚ β”œβ”€β”€ wsgi.py β”‚ └── wsgi.pyc β”œβ”€β”€ manage.py └── polls β”œβ”€β”€ admin.py β”œβ”€β”€ admin.pyc β”œβ”€β”€ __init__.py β”œβ”€β”€ __init__.pyc β”œβ”€β”€ migrations β”‚ β”œβ”€β”€ 0001_initial.py β”‚ β”œβ”€β”€ 0001_initial.pyc β”‚ β”œβ”€β”€ __init__.py β”‚ └── __init__.pyc β”œβ”€β”€ models.py β”œβ”€β”€ models.pyc β”œβ”€β”€ tests.py β”œβ”€β”€ urls.py β”œβ”€β”€ urls.pyc β”œβ”€β”€ views.py └── views.pyc

and, as in the survey tutorial /urls.py :

 from django.conf.urls import url from . import views urlpatterns = { url(r'^$', views.index, name='index'), } 

and for my dj_project / urls.py :

 from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), url(r'^admin/', include(admin.site.urls)), ] 

and in polls /views.py I have:

 from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse("is there something here?") 

so when I go to <mysite>/polls , I see that "there is something here", but if I go to <mysite>/admin , I get an error: TypeError at /admin/ argument to reversed() must be a sequence . If I delete polls from urlpatterns in dj_project/urls.py , the admin comes in order.

What could be the problem? I don't seem to understand.

+4
source share
1 answer

In the file polls / urls.py you declare urlpatterns as a dict, it should be a list.

change

 urlpatterns = { url(r'^$', views.index, name='index'), } 

in

 urlpatterns = [ url(r'^$', views.index, name='index'), ] 
+21
source

All Articles