Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.32 KB

File metadata and controls

56 lines (44 loc) · 1.32 KB

Mongoengine Model Serializer

Model Serializer that supports MongoEngine, for Django Rest Framework.


Usage

# model
class Blog(Document):
    owner = ReferenceField(User)
    title = StringField()
    extensions = ListField(EmbeddedDocument(BlogExtension))
    tags = ListField(StringField())
    approved = BooleanField()

# serializer
class BlogSerializer(MongoEngineModelSerializer):
    class Meta:
        model = Blog
        depth = 2
        exclude = ('approved', )

Notes:

  • MongoEngine Model Serializer also supports DynamicDocument.
  • Depth is optional and defaults to 5. It is used for ReferenceField & ListField.

Sample Output

Sample Output


Install

pip install django-rest-framework-mongoengine


Requirements


License

See LICENSE