from django.shortcuts import render
from django.http import HttpResponse
booksList = [
{ 'id' = '1',
'title' = "Beginner's Course in Django",
'description' = 'Foundational Course in Django'}
{ 'id' = '2',
'title' = "Intermediate Course in Django",
'description' = 'Next steps in Django'
},
{
'id' = '3',
'title' = "Advanced Course in Django",
'description' = 'The complexities of Django'
},
]我使用上面的bookList将数据呈现给一个模板,并得到两个错误:
'[‘不是关闭的Pylance’和'{‘不是关闭Pylance’
敬请指教。
发布于 2021-12-17 06:14:11
我刚刚发现了错误:冒号(:)应该用来代替等号(=).The,下面的代码工作如下:
from django.shortcuts import render
from django.http import HttpResponse
booksList = [
{ 'id' : '1',
'title' : "Beginner's Course in Django",
'description' : 'Foundational Course in Django'},
{ 'id' : '2',
'title' : "Intermediate Course in Django",
'description' : 'Next steps in Django'
},
{
'id' : '3',
'title' : "Advanced Course in Django",
'description' : 'The complexities of Django'
},
]https://stackoverflow.com/questions/70387952
复制相似问题