Question

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

I 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 that shop has list of items. And when I make a request to REST url for the shop, the shop and the item list should be serialized into JSON and response is sent to client.

How can I do that? Which REST framework is suitable for that case?

Should I keep items in the shop class?(e.g items=(ListField(ReferenceField(Item))))

Was it helpful?

Solution

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

This worked great!

OTHER TIPS

I think using generic views would be the easiest way, afaik there is no REST / Mongoengine framework available.

Have you checked out tastypie-mongo engine? It's a Django application that provides MongoEngine support for Tastypie.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top