小编Gir*_* Ns的帖子

如何将django rest框架响应传递给html?

如何将任何请求的django restframework响应传递给html.示例:包含对象的列表,html为articles.html.

我尝试使用rest框架Response:

data= {'articles': Article.objects.all() }
return Response(data, template_name='articles.html')
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

""" AssertionError at /articles/

.accepted_renderer not set on Response """
Run Code Online (Sandbox Code Playgroud)

哪里出错了,请建议我.

python django django-rest-framework

20
推荐指数
3
解决办法
3万
查看次数

如何在python中将字符串转换为变量

如何在python中将'a = b = 2'字符串转换为a = 2,b = 2?

有一些python解析器为2 + 3 + 4等表达式提供输出.

但是如何将'a = b = 2'字符串用作变量a = 2 b = 2

python

0
推荐指数
1
解决办法
6702
查看次数

标签 统计

python ×2

django ×1

django-rest-framework ×1