134👍
✅
You can do:
class BasicSerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
fields = ('lengthy', 'touple', 'of', 'fields', 'like', '10', 'of', 'them')
class AdvandedSerializer(BasicSerializer):
additional_field = serializers.SerializerMethodField()
def get_additional_field(self, obj):
return('not important')
class Meta(BasicSerializer.Meta):
fields = BasicSerializer.Meta.fields + ('additional_field',)
25👍
we can do like
class AdvandedSerializer(BasicSerializer):
# ... some code
class Meta:
model = MyModel
fields = BasicSerializer.Meta.fields + ('additional_field',)
- [Django]-What is an efficient way of inserting thousands of records into an SQLite table using Django?
- [Django]-DatabaseError: current transaction is aborted, commands ignored until end of transaction block?
- [Django]-Good open source django project for learning
Source:stackexchange.com