• Using primary keys.
    • Using hyperlinking between entities.
    • Using the default string representation of the related entity.
    • Nesting the related entity inside the parent representation.

    REST framework supports all of these styles, and can apply them across forward or reverse relationships, or apply them across custom managers such as generic foreign keys.

    The HyperlinkedModelSerializer has the following differences from ModelSerializer:

    • It does not include the id field by default.
    • It includes a field, using HyperlinkedIdentityField.

    Notice that we've also added a new field. This field is of the same type as the url field, except that it points to the 'snippet-highlight' url pattern, instead of the 'snippet-detail' url pattern.