【发布时间】:2019-01-22 06:56:41
【问题描述】:
无论如何要在 json django 中编辑响应?我正在使用 view.viewset
{
"title": "Cloister",
"number": 2,
"summary": "Erasmas describes several buildings of the Concent, namely the Scriptiorium...",
"page_count": 14
},
例如:首先我在json中得到这样的“title”:“Cloister”,我想在get string之后添加一些东西,最终结果必须是:“title”:“Cloister+somethinghere”!
我的任务是获取产品名称,并检查名称是否 >40 个字符,然后只取 40 个字符并在 40 个字符后加上“...”
【问题讨论】:
-
所以你想返回一个标题不超过 40 个字符的 json。如果它应该超过 3 个字符并且带有 3 个尾随点?
标签: python django django-rest-framework