python - Django SerializerModel does not return the fields -
i create django rest api serializer if test serializer receive empty result.
actually should receive
>>> heating.serializers import roomserializer >>> s = roomserializer() >>> print(repr(s)) roomserializer(): ... list of fields additional infomration... >>>
model
class room(models.model): id = models.integerfield(auto_created=true, primary_key=true) name = models.charfield(max_length=100, blank=true, default='') description = models.textfield() class meta: ordering = ['id']
serializer
class roomserializer(serializers.modelserializer): class meta: model = room fields = ('id', 'name', 'description')
shell output
>>> heating.serializers import roomserializer >>> s = roomserializer() >>> print(repr(s)) roomserializer(): >>>
i belive, there mistake in code, have no clue where?
you didn't provide information serializer, why should return data when none provided ?
please take time go through tutorial
Comments
Post a Comment