Merge pull request #3497 from Ins1ne/feature/3340

update docs about detail page link for AdminRenderer
This commit is contained in:
Xavier Ordoquy 2015-11-18 17:38:07 +01:00
commit edc5a79b85
2 changed files with 17 additions and 7 deletions

View File

@ -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**: The `AdminRenderer` is only able to include links to detail pages when a properly configured `URL_FIELD_NAME` (`url` by default) attribute is present in the data. For `HyperlinkedModelSerializer` this will be the case, but for `ModelSerializer` or plain `Serializer` classes you'll need to make sure to include the field explicitly. 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'`

View File

@ -13,8 +13,9 @@
</td>
{% endif %}
{% endfor %}
<td><a href="{{ row.url }}"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
</a></td>
<td>
<a href="{{ row.url }}"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a>
</td>
</tr>
{% endfor %}
</tbody>