Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django tutorial, Getting: TypeError at /admin/ argument to reversed() must be a sequence

I'm working my way through the django tutorial for version 1.8 and I am getting an error that I am stuck on and can't seem to figure out. I thought I was following the tutorial pretty much to the T.

I have the following tree set up:

. ├── 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 have, just as in the tutorial for polls/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 "is there something here", but if I go to <mysite>/admin, I get the error: TypeError at /admin/ argument to reversed() must be a sequence. If I remove polls from urlpatterns in dj_project/urls.py, the admin comes in fine.

What might be the problem? I can't seem to figure it out.

like image 637
roy Avatar asked Aug 14 '15 16:08

roy


1 Answers

In the polls/urls.py file, you are declaring the urlpatterns as dict, it must be a list.

change the

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

to:

urlpatterns = [
    url(r'^$', views.index, name='index'),
]
like image 79
v1k45 Avatar answered Oct 30 '22 02:10

v1k45