Пример #1
0
class GroupSerializer(serializers.HyperlinkedModelSerializer):
    permissions = serializers.ManySlugRelatedField(
        slug_field='codename', queryset=Permission.objects.all())

    class Meta:
        model = Group
        fields = ('url', 'name', 'permissions')
Пример #2
0
class GroupSerializer(serializers.ModelSerializer):

    permissions = serializers.ManySlugRelatedField(
        slug_field='codename', queryset=Permission.objects.all())

    users = serializers.ManyPrimaryKeyRelatedField('user_set')
    url = serializers.HyperlinkedIdentityField(view_name='group-detail')

    class Meta(object):
        model = Group
Пример #3
0
class ForeignKeyTargetSerializer(serializers.ModelSerializer):
    sources = serializers.ManySlugRelatedField(slug_field='name')

    class Meta:
        model = ForeignKeyTarget