【发布时间】:2011-05-31 16:16:57
【问题描述】:
我在 django 模板中有以下代码:
{% for object in object_list %}
{% with game=object.game %}
<a href="{% url game_view game.id game.title|slugify %}" class="img_link alphabeticList">{{game.title}}</a>
{% endwith %}
{% endfor %}
输出当前类别下的所有游戏,例如:
Armor Dude
Midnight Strike
Super Mafia Bros
Mission To Mars
Zed
game1 test 3
Examine the mystery of the crime in Apartment 13
Manor Freedom : The Patron's Chamber
Escape Journey
Outrun Summer Camp
Make your way through zombies hordes
Intelligent Guy
Run 3D : The Bathroom
Lady Gaga Escape Game
Insane Box
Will you do me A Small Favor?
Shanty Breakout
Cloudy Tumble Second Chaptert
Hotel Area Lock In
Escape From the Aircraft Hangar
RANDOM GAMES
Scene of the Caper: Gold Toy Scene of the Caper: ...
Escape Journey Escape Journey
Cloudy Tumble Second Chaptert Cloudy Tumble Second...
Midnight Strike Midnight Strike
BB EXCLUSIVES
Soldier Of Pain Soldier Of Pain
Walk The Stork Walk The Stork
我怎样才能让输出按字母顺序和每个游戏标题开头的字母排序,例如:
A
---
Apple
Alligator
B
---
Burger
Bungee
Bear
C
---
cat
等等……
请注意,我只能使用模板标签,无法访问任何 python 代码。
【问题讨论】:
-
我猜你不允许编写自定义标签?
-
@digitaldreame 不,我是前端开发人员
-
那么使用 Javascript 对它们重新排序怎么样?