[Django]-Django + SQLAlchemy + RESTful API (tastypie?)


You might want to take a look at the following page in the tastypie documentation:


Specifically, the riak example seems good and the kind of thing that you need to implement.


Tastypie does work with SQLAlchemy.

Check out tastyalchemy @ github – it is a good start for how to build a SQLAlchemyResource for Tastypie. Using it, you can create a resource for an SQLAlchemy ORM class like:

class MyORMResource(SQLAlchemyResource):
    class Meta:
        resource_name = 'myorm'
        object_class = MySQLAlchemyORMClass
        allowed_methods = ['get', 'post', 'put', 'delete']

I found I needed to implement SQLAlchemyResource.post_detail() to get the updating to work, and I handle my sessions differently so I had to change a few things, but if you don’t mind reading through tastypie’s resource.py it is pretty easy to get up and running. Foreign keys work too, although haven’t found a way to get a One to Many relationship to work yet.

Leave a comment