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

后端 未结 7 2391
北海茫月
北海茫月 2020-12-06 10:36

I am new to django and python. During url mapping to views i am getting following error: TypeError: view must be a callable or a list/tuple in the case of include().

<
7条回答
  •  攒了一身酷
    2020-12-06 11:35

    Replace your admin url pattern with this

    url(r'^admin/', include(admin.site.urls))
    

    So your urls.py becomes :

    from django.conf.urls import url, include
    from django.contrib import admin
    
    
    urlpatterns = [
        url(r'^admin/', include(admin.site.urls)),
        url(r'^posts/$', "posts.views.post_home"), #posts is module and post_home 
    ] 
    

    admin urls are callable by include (before 1.9).

提交回复
热议问题