93👍
✅
Create another serializer say BLContainerSerializer
and exclude fields there. Then use this in your BLcontainerMergedSerializer
. Hope this helps.
class BLContainerSerializer(serializers.ModelSerializer):
class Meta:
model = Container
exclude = ('field1', )
class BLcontainerMergedSerializer(serializers.ModelSerializer):
container = BLContainerSerializer()
class Meta:
model = BLcontainer
6👍
There is a fields meta property:
class BLcontainerMergedSerializer(serializers.ModelSerializer):
container = ContainerSerializer()
class Meta:
model = BLcontainer
fields = ('field1', 'field2')
Reference: Django REST docs
- [Django]-Automated django receive hook on server: respond to collectstatic with "yes"
- [Django]-Handling race condition in model.save()
- [Django]-Check if OneToOneField is None in Django
Source:stackexchange.com