有没有办法在 Django REST Framework JSON API 中显示有关关系字段的更多详细信息
Is there a way to show more details about a Relational Field in Django REST Framework JSON API
我正在尝试使用 Django REST Framework JSON API 并且想知道是否有一种方法可以序列化关系(ForeignKey 和所有),与 :
"post": {
"type": "Post",
"id": 1
}
我在想一些类似的事情:
"post": {
"type": "Post",
"id": 1,
"name": "First Post"
"tag": "Development"
}
class AlbumSerializer(serializers.ModelSerializer):
tracks = serializers.StringRelatedField(many=True)
class Meta:
model = Album
fields = ('album_name', 'artist', 'tracks')
关系看这里:http://www.django-rest-framework.org/api-guide/relations/
我正在尝试使用 Django REST Framework JSON API 并且想知道是否有一种方法可以序列化关系(ForeignKey 和所有),与 :
"post": {
"type": "Post",
"id": 1
}
我在想一些类似的事情:
"post": {
"type": "Post",
"id": 1,
"name": "First Post"
"tag": "Development"
}
class AlbumSerializer(serializers.ModelSerializer):
tracks = serializers.StringRelatedField(many=True)
class Meta:
model = Album
fields = ('album_name', 'artist', 'tracks')
关系看这里:http://www.django-rest-framework.org/api-guide/relations/