Skip to content

Commit 25bb3b1

Browse files
committed
Use chevron control for row linking, rather than hyperlinking first item
1 parent 90f2e26 commit 25bb3b1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

rest_framework/renderers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,10 @@ def get_context(self, data, accepted_media_type, renderer_context):
730730

731731
columns = [key for key in header.keys() if key != 'url']
732732
details = [key for key in header.keys() if key != 'url']
733-
linked = [columns[0]] if columns else []
734733

735734
context['style'] = style
736735
context['columns'] = columns
737736
context['details'] = details
738-
context['linked'] = linked
739737
context['results'] = results
740738
return context
741739

rest_framework/templates/rest_framework/admin/list.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{% load rest_framework %}
22
<table class="table table-striped">
33
<thead>
4-
<tr>{% for column in columns%}<th>{{ column|capfirst }}</th>{% endfor %}</tr>
4+
<tr>{% for column in columns%}<th>{{ column|capfirst }}</th>{% endfor %}<th></th></tr>
55
</thead>
66
<tbody>
77
{% for row in results %}
88
<tr>
99
{% for key, value in row.items %}
1010
{% if key in columns %}
1111
<td {{ value|add_nested_class }} >
12-
{% if key in linked %}<a href="{{ row.url }}">{% endif %}
1312
{{ value|format_value }}
14-
{% if key in linked %}</a>{% endif %}
1513
</td>
1614
{% endif %}
1715
{% endfor %}
16+
<td><a href="{{ row.url }}"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
17+
</a></td>
1818
</tr>
1919
{% endfor %}
2020
</tbody>

rest_framework/templatetags/rest_framework.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def format_value(value):
134134

135135
@register.filter
136136
def add_nested_class(value):
137-
if isinstance(value, (list, dict)):
137+
if isinstance(value, dict):
138+
return 'class=nested'
139+
if isinstance(value, list) and any([isinstance(item, (list, dict)) for item in value]):
138140
return 'class=nested'
139141
return ''
140142

0 commit comments

Comments
 (0)