TypeError: view must be a callable or a list/tuple in the case of include(). in urls.py

1,231 views
Skip to first unread message

arun kumar

unread,
Sep 5, 2016, 9:06:37 AM9/5/16
to Django users
Hi,

   I'm working in Django 1.10 and I got the type error  in the below file at this line " url(r'^$', views.dashboard, name = 'dashboard'),"

from django.conf.urls import include, url
from . import views

urlpatterns = [
    #preview login view
    #url(r'^login/$',views.user_login, name='login')

    # logged - in user dashboard
    url(r'^$', views.dashboard, name = 'dashboard'),

    #login / logout urls
    url(r'^login/$', 'django.contrib.auth.views.login', name='login'),

    url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),

    url(r'^logout-then-login/$','django.contrib.auth.views.logout_then_login', name='logout_then_login')

]

I'm new to Django and stuck because of this 

Abraham Varricatt

unread,
Sep 5, 2016, 10:26:34 AM9/5/16
to Django users
Not sure what the issue is without more info about the error, but is the regular expression for that view correct? Assuming that you want to divert folks to the root of your site can you try the following?

url(r'^/$', views.dashboard, name = 'dashboard')


NOTE: if the error still persists, it will help if you include the full traceback in your email.

Yours,
Abraham V.

James Schneider

unread,
Sep 5, 2016, 11:35:10 PM9/5/16
to django...@googlegroups.com

On Sep 5, 2016 6:06 AM, "arun kumar" <arunkumar...@gmail.com> wrote:
>
> Hi,
>
>    I'm working in Django 1.10 and I got the type error  in the below file at this line " url(r'^$', views.dashboard, name = 'dashboard'),"
>
> from django.conf.urls import include, url
> from . import views
>
> urlpatterns = [
>     #preview login view
>     #url(r'^login/$',views.user_login, name='login')
>
>     # logged - in user dashboard
>     url(r'^$', views.dashboard, name = 'dashboard'),
>
>     #login / logout urls
>     url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
>

Here is where your problem starts. Django 1.10 removed the ability to use string arguments to refer to views. See the deprecation notice in 1.8:

https://docs.djangoproject.com/en/1.8/ref/urls/#django.conf.urls.url

Import your views and pass them along directly.

-James

Reply all
Reply to author
Forward
0 new messages