Mongoengine support for Django Rest Framework.
Starting from version 2.0
, this package will be developed using DRF 3.0
and higher.
If you want to use DRFME
with DRF 2
, you should version 1.*
. Development will be continued on drf_2_support
branch.
See full documentation here
DocumentSerializer
works just like as DRF Model Serializer
. Your model fields are converted to relevant serializer fields automatically. If you want custom behavior, you can use nested serializers
.
from rest_framework_mongoengine.serializers import DocumentSerializer
class BlogSerializer(DocumentSerializer):
class Meta:
model = Blog
fields = ('id', 'author', 'name', 'date_created')
A DocumentSerializer
for dynamic documents.
EmbeddedDocumentSerializer
is used to customize EmbeddedDocument
behavior, and make validations
accurately. It is mentioned extensively on the documentation
Generic Views
are named exactly the same as DRF Generic Views
.
Just make sure you are using DRFME Generics
.
from rest_framework_mongoengine import generics
pip install django-rest-framework-mongoengine
Note: You might consider using a specific version.
For clarity:
- DRF2 support:
pip install "django-rest-framework-mongoengine<2.0"
- DRF3 support:
pip install "django-rest-framework-mongoengine>=2.0"
Don't forget to add the package to installed apps.
INSTALLED_APPS = (
...
'rest_framework_mongoengine',
)
@Jcbobo88
@qwiglydee
Feel free to mail me if you consider being a maintainer.