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

2,969 views
Skip to first unread message

herve kabore

unread,
Aug 23, 2018, 5:48:14 PM8/23/18
to Django users
this is the urls.py


from django.conf.urls import url
from django.contrib import admin

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

     url(r'^$', 'blog.views.home', name='home'),
]


this is the views


from django.shortcuts import render

from django.http import HttpResponse

# Create your views here.

def home(request):
    return HttpResponse("Bonjour monde!")



Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f8f4a8afe18>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/lib/python3/dist-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 256, in check
    for pattern in self.url_patterns:
  File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/herve/Bureau/mes_projets/eboutique/eboutique/urls.py", line 20, in <module>
    url(r'^$', 'backoffice.views.home', name='home'),
  File "/usr/lib/python3/dist-packages/django/conf/urls/__init__.py", line 85, in url
    raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().

Glen D souza

unread,
Aug 25, 2018, 3:20:50 AM8/25/18
to django...@googlegroups.com
  url(r'^$', 'blog.views.home', name='home')

You are passing a string as view by quoting blog.views.home

remove the quotes and try, i.e  url(r'^$', blog.views.home, name='home')

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aware Fun

unread,
Aug 25, 2018, 3:24:33 AM8/25/18
to django...@googlegroups.com


rahul

On Fri, Aug 24, 2018, 3:17 AM herve kabore <kabore...@gmail.com> wrote:
this is the urls.py


from django.conf.urls import include,url

ansh srivastav

unread,
Aug 25, 2018, 6:41:18 AM8/25/18
to django...@googlegroups.com
Use the following in urls.py:



  from django.conf.urls import include,url

Reply all
Reply to author
Forward
0 new messages