开发者社区 问答 正文

如何在没有Python的情况下使用generic.ListView将“.L”解释为单独的语法?

我在Django中定义了一个通用索引视图,但是当调用“generic.ListView”作为参数时,由于某种原因,Python将.ListView中的“.L”解释为其他东西,并返回语法错误。

它与generic.DetailView一起工作正常,并且只有在L跟随一段时间后它才会被不同地解释。我试过谷歌搜索.L是什么,如果有一个更改如何调用.ListView等无济于事

这是索引调用:

def IndexView(generic.ListView):

template_name = 'form/index.html'
context_object_name = 'latest_entries_list'

这是详细信息调用,效果很好:

def DetailView(generic.DetailView):

model = Info
template_name = 'form/detail.html'

展开
收起
一码平川MACHEL 2019-01-16 18:09:50 2563 分享 版权
2 条回答
写回答
取消 提交回答
问答分类:
问答标签:
问答地址: