mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Merge pull request #3497 from Ins1ne/feature/3340
update docs about detail page link for AdminRenderer
This commit is contained in:
commit
edc5a79b85
|
@ -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'`
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user