首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将书单呈现为模板时出错

将书单呈现为模板时出错
EN

Stack Overflow用户
提问于 2021-12-17 03:02:01
回答 1查看 123关注 0票数 0
代码语言:javascript
复制
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’

敬请指教。

EN

回答 1

Stack Overflow用户

发布于 2021-12-17 06:14:11

我刚刚发现了错误:冒号(:)应该用来代替等号(=).The,下面的代码工作如下:

代码语言:javascript
复制
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'
             },
     
              ]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70387952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档