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

后端 未结 7 2466
北海茫月
北海茫月 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:27

    For Django 1.11.2
    In the main urls.py write :

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

    And in the appname/urls.py file write:

    from django.conf.urls import url
    from . import views
    
    urlpatterns = [
        url(r'^$',views.post_home),
    ]
    

提交回复
热议问题