Vendors¶
Django¶
Serializer for easily converting to and from simple Python datatypes to Django Models.
-
class
avocato.vendors.django.
DjangoModelSerializer
(instance=None, many=False, data=None, **kwargs)¶ Class for converting to and from simple Python datatypes to Django Models.
Example:
class ModelFoo(django.db.models.Model): bar = models.IntegerField() baz = models.CharField() class FooSerializer(DjangoModelSerializer): class Meta: model = ModelFoo fields =['bar', 'baz'] obj = ModelFoo(bar=2, baz='hello') FooSerializer(obj).data # {'bar': 2, 'baz': 'hello'}
-
create
(data)¶ Override this function if you want to do something custom when creating an object.
-
save
()¶ Saves the instance with the help of Django models
.save()
method.
-
update
(data)¶ Override this function if you want to do something custom when updating an object.
-
peewee¶
Serializer for easily converting to and from simple Python datatypes to peewee models.
-
class
avocato.vendors.peewee.
PeeWeeModelSerializer
(instance=None, many=False, data=None, **kwargs)¶ Class for converting to and from simple Python datatypes to peewee models.
Example:
class ModelFoo(peewee.Model): bar = peewee.IntegerField() baz = peewee.CharField() class FooSerializer(PeeweeModelSerializer): class Meta: model = ModelFoo fields =['bar', 'baz'] obj = ModelFoo(bar=2, baz='hello') FooSerializer(obj).data # {'bar': 2, 'baz': 'hello'}
-
create
(data)¶ Override this function if you want to do something custom when creating an object.
-
save
()¶ Saves the instance with the help of peewee models
.save()
method.
-
update
(data)¶ Override this function if you want to do something custom when updating an object.
-