Simply Seth
Aug 9, 2017 · 1 min read

Is there an example somewhere of using both databases ?

I’m trying to use sqlite and mongodb at the same time.

To make both co-exist I’m doing imports like …

from rest_framework import serializers
from rest_framework_mongoengine import serializers as dserializers
class PlaybookSerializer(dserializers.DocumentSerializer):
class Meta:
model = Playbook
fields = '__all__'
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')

And …

from django.conf.urls import url, include
from rest_framework import routers
from rest_framework_mongoengine import routers as drouters
from runner import views
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
drouter = drouters.DefaultRouter()
drouter.register(r'playbooks', views.PlaybookViewSet)

urlpatterns = [
url(r'^', include(router.urls,drouter.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^playbooks/', include('rest_framework.urls', namespace='rest_framework'))
]

Is this the correct way to go about this ?

Thanks.

    Simply Seth

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade