python - How can I include fields from Base serializer in django rest framework? -
i have code
class baseserializer(serializers.modelserializer): unicode = serializers.serializermethodfield('get_unicode') class meta: fields=('unicode',) def get_unicode(self): return 'test'
i want fields in base serializer come in sub classes of it
class entryserializer(baseserializer): class meta: model = models.entry fields = ('id', 'start_time', 'end_time')
but not contain unicode in output
is there way fields added in base serializer gets automatically appended sub classes , without manually adding name. want o keep common fields in classes in base
you can this. include field of base serializer.
class entryserializer(serializers.modelserializer): base= baseserializer() class meta: model = models.entry fields = ('base','id', 'start_time', 'end_time')
Comments
Post a Comment