diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md index 614259458..1cf924341 100644 --- a/docs/api-guide/renderers.md +++ b/docs/api-guide/renderers.md @@ -187,6 +187,15 @@ This renderer is suitable for CRUD-style web APIs that should also present a use Note that views that have nested or list serializers for their input won't work well with the `AdminRenderer`, as the HTML forms are unable to properly support them. +**Note**: To get proper links to detail page in `ListCreateAPIView` or `ListAPIView` you should implement `url` field in serializer which return correct link. For example here we use models `get_absolute_url` method: + + class AccountSerializer(serializers.ModelSerializer): + url = serializers.CharField(source='get_absolute_url', read_only=True) + + class Meta: + model = Account + + **.media_type**: `text/html` **.format**: `'.admin'` diff --git a/rest_framework/templates/rest_framework/admin.html b/rest_framework/templates/rest_framework/admin.html index e1751b21c..318a1e706 100644 --- a/rest_framework/templates/rest_framework/admin.html +++ b/rest_framework/templates/rest_framework/admin.html @@ -219,7 +219,7 @@ {% endif %} {% block script %} - + diff --git a/rest_framework/templates/rest_framework/admin/list.html b/rest_framework/templates/rest_framework/admin/list.html index a3ec21af3..048843bb7 100644 --- a/rest_framework/templates/rest_framework/admin/list.html +++ b/rest_framework/templates/rest_framework/admin/list.html @@ -7,14 +7,15 @@ {% for row in results %} {% for key, value in row.items %} - {% if key in columns %} - - {{ value|format_value }} - - {% endif %} + {% if key in columns %} + + {{ value|format_value }} + + {% endif %} {% endfor %} - - + + + {% endfor %}