我使用Django模板在谷歌应用程序Eninge上。
I want to truncate string after a given number of chars, for example, if a string (a title of a post) is too long, "This is a long long long long title", I want to display the first few words, like this: "This is a long long ..."
我在这里找到了一些Django代码片段:http://djangosnippets.org/snippets/1259/http://djangosnippets.org/snippets/763/一
我想知道:
Google App Engine python中是否有更简单的解决方案?
How can I use this snippet http://djangosnippets.org/snippets/1259/ in App Engine? I believe messing source code is not a good idea.
我需要在Django模板中截断字符串,而不是在python源代码中。类似这样的内容:{{string|truncatesmart:50}}