Skip to content

neodark/django-rest-framework-mongoengine

 
 

Repository files navigation

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
from rest_framework_mongoengine.serializers import MongoEngineModelSerializer

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


Install as package

You can use this library as a package to your project:

  • Step 1: Installing required files pip install -r requirements.txt
  • Step 2: make sure you're having a mongodb running locally: /bin/mongod --dbpath [path_to_data/db/]
  • Step 3: Create users and table in dbsqlite and django admin: python manage.py syncdb
  • Step 4: Run the SampleApp demo: python manage.py runserver

Then run http://localhost:8000/ on your favorite browser to test the interface


Requirements


License

See LICENSE

About

MongoEngine Model Serializer for Django Rest Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%