Home > database >  I am getting: TypeError: view must be a callable or a list/tuple in the case of include()
I am getting: TypeError: view must be a callable or a list/tuple in the case of include()

Time:09-15

My root urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('', include('webarticles.urls')),
]

While I have seen this error answered on stackoverflow before, they don't seem to work for me. Specifically there are 2 components of the answers that confuse me:

  1. Why url is used instead of path
  2. If I am to import webarticles, how to do that given that my project and app are on the same level

Thank you for any help you are able to provide!

CodePudding user response:

Make sure your urls.py in webarticles app has the following too:

urlpatterns = [
   path('', views.index, name='index'),
]

Or whatever url list you are using in your app.

CodePudding user response:

======== For Project urls.py ========

from django.contrib import admin
from django.urls import path,include


urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include("webarticles.urls")),

]

======== For webarticles (app) urls.py ========

from django.urls import path
from webarticles.views import *


urlpatterns = [
    path('',DemoView1,name="demo1"),
    path('demo2/', DemoView2, name="demo2"),
    path('demo3/', DemoView3, name="demo3"),

]
  • Related