diff --git a/rest_framework/static/rest_framework/css/default.css b/rest_framework/static/rest_framework/css/default.css index ede54bd17..7e33aee32 100644 --- a/rest_framework/static/rest_framework/css/default.css +++ b/rest_framework/static/rest_framework/css/default.css @@ -33,6 +33,14 @@ h2, h3 { margin-right: 1em; } +td.nested { + padding: 0 !important; +} + +td.nested > table { + margin: 0; +} + form select, form input, form textarea { width: 90%; } diff --git a/rest_framework/templates/rest_framework/admin/dict_value.html b/rest_framework/templates/rest_framework/admin/dict_value.html new file mode 100644 index 000000000..e69de29bb diff --git a/rest_framework/templates/rest_framework/admin/list.html b/rest_framework/templates/rest_framework/admin/list.html index 6b72442cf..e8c547a6c 100644 --- a/rest_framework/templates/rest_framework/admin/list.html +++ b/rest_framework/templates/rest_framework/admin/list.html @@ -8,7 +8,7 @@
{{ forloop.counter0 }} | +{{ item|format_value }} | +
---|
%s
' % value)
elif isinstance(value, list):
- return ''
+ template = loader.get_template('rest_framework/admin/list_value.html')
+ context = Context({'value': value})
+ return template.render(context)
elif isinstance(value, dict):
- return ''
+ template = loader.get_template('rest_framework/admin/dict_value.html')
+ context = Context({'value': value})
+ return template.render(context)
elif isinstance(value, six.string_types):
if (
(value.startswith('http:') or value.startswith('https:')) and not
@@ -124,6 +129,12 @@ def format_value(value):
return six.text_type(value)
+@register.filter
+def add_nested_class(value):
+ if isinstance(value, (list, dict)):
+ return 'class=nested'
+ return ''
+
# Bunch of stuff cloned from urlize
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)', '"', "']", "'}", "'"]