对于include(),视图必须是可调用的或列表/元组

时间:2019-12-20 17:09:03

标签: python django

    File "/home/bsd/PycharmProjects/BSD/BSD_2_7/BSD_2_7/urls.py", line 10, in <module>
    url('$', 'base.views.index'),
   File "/usr/local/lib/python3.6/dist-packages/django/conf/urls/__init__.py", line 13, in 
  url
    return re_path(regex, view, kwargs, name)
   File "/usr/local/lib/python3.6/dist-packages/django/urls/conf.py", line 73, in _path
    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().

   urlpatterns = [
    url('$', 'myapp.views.index')]

我正在使用django 2.2,pythong 3.6。以前用Django 1.7编写的应用程序,我不知道如何将错误修复为Django 2.2。

当我尝试做

from myapp.views import index
and url('$', index, name="index")]

从myapp.views中看不到

myapp文件夹,views.py

  

@login_required
def index (request):

0 个答案:

没有答案