How to use RESTful services with Django + Mongoengine?

I want to use my django web application with RESTful services.

I have already created my models using mongoengine. Let's say I have 2 models:

class Shop(Document): name = StringField() description = StringField() address = StringField() image_path = StringField() class Item(Document): name = StringField() description = StringField() shop = ReferenceField(Shop) images = ListField(StringField()) 

In this scenario, I want this store to have a list of items. And when I make a request for a REST URL for the store, the store and product list must be serialized in JSON, and the response is sent to the client.

How can i do this? Which REST structure is appropriate for this case?

Should I store items in a store class? (e.g. items = (ListField (ReferenceField (Item))))

+4
source share
3 answers

I used Piston in Django with custom model classes built using MongoEngine.

It worked great!

+1
source

I think using shared views would be the easiest way, afaik there are no available REST / Mongoengine.

0
source

Have you checked the tastypie-mongo engine? This is a Django app that supports MongoEngine for Tastypie.

http://django-tastypie-mongoengine.readthedocs.org/en/latest/usage.html#simple-example

0
source

Source: https://habr.com/ru/post/1401084/


All Articles