TypeError: 'function' object has no attribute '__getitem__' from urls.py

TypeError: 'function' object has no attribute '__getitem__' from urls.py

当我尝试在 Django 中迁移(manage.py 迁移)时,出现以下错误:

File "C:\Program Files\Python27\Scripts\Folder_Name\Folder_Name\urls.py", line 22, in <module>      
    url[(r'^$',ListView.as_view(queryset=ABC.objects.all(),template_name="Folder_Name/Folder_Name.html"))],
TypeError: 'function' object has no attribute '__getitem__'

下面是我对 Folder_Name/urls.py

的了解
from django.conf.urls import url, include
from django.views.generic import ListView, DetailView
from Folder_Name.models import ABC

urlpatterns = [

    url[(r'^$', ListView.as_view(queryset=IOC.objects.all(),template_name="Folder_Name/Folder_Name.html"))],

]

如有任何帮助,我们将不胜感激。谢谢你。

url.

的参数周围有不必要的方括号

url模式不是这样写的

在此处阅读更多内容:https://docs.djangoproject.com/en/1.10/topics/http/urls/

这样写:(去掉url[..]的列表)

urlpatterns = [

    url(r'^$', ListView.as_view(queryset=IOC.objects.all(),template_name="Folder_Name/Folder_Name.html")),

]