18๐
I believe the recently released django-piston is now the best solution for creating a proper REST interface in Django. django-piston
Note: django-piston seems to no longer be maintained (see comments below)
41๐
For Django, besides tastypie and piston, django-rest-framework is a promising one worth mentioning. Iโve already migrated one of my projects on it smoothly.
Django REST framework is a lightweight REST framework for Django, that
aims to make it easy to build well-connected, self-describing RESTful
Web APIs.
Quick example:
from django.conf.urls.defaults import patterns, url
from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from myapp.models import MyModel
class MyResource(ModelResource):
model = MyModel
urlpatterns = patterns('',
url(r'^$', ListOrCreateModelView.as_view(resource=MyResource)),
url(r'^(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=MyResource)),
)
Take the example from the official site, all above codes provide api, self explained documentation (like soap based webservice) and even sandboxing for testing. Very convenient.
- [Django]-Select DISTINCT individual columns in django?
- [Django]-In Django, how do I check if a user is in a certain group?
- [Django]-Annotate a queryset with the average date difference? (django)
9๐
django-tastypie is a good way to do it, their slogan: โCreating delicious APIs for Django apps since 2010โ is pretty comforting ๐
- [Django]-Django dynamic forms โ on-the-fly field population?
- [Django]-A good way to redirect with a POST request?
- [Django]-How to pass django rest framework response to html?
5๐
You could take look at django-dynamicresponse, which is a lightweight framework for adding REST API with JSON to your Django applications.
It requires minimal changes to add API support to existing Django apps, and makes it straight-forward to build-in API from the start in new projects.
Basically, it includes middleware support for parsing JSON into request.POST, in addition to serializing the returned context to JSON or rendering a template/redirecting conditionally based on the request type.
This approach differs from other frameworks (such as django-piston) in that you do not need to create separate handlers for API requests. You can also reuse your existing view logic, and keep using form validation etc. like normal views.
- [Django]-Django error message "Add a related_name argument to the definition"
- [Django]-Running a specific test case in Django when your app has a tests directory
- [Django]-How can I get the full/absolute URL (with domain) in Django?
4๐
I donโt know if this project can be useful for you, but sending a link can hardly hurt. Take a look at django-apibuilder , available from http://opensource.washingtontimes.com/projects/django-apibuilder/ . Perhaps it can be useful?
/Jesper
- [Django]-Django render_to_string missing information
- [Django]-Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5
- [Django]-Django TypeError: get() got multiple values for keyword argument 'invoice_id'
- [Django]-How do I use CSS in Django?
- [Django]-Django Test Client Method Override Header
- [Django]-Why is factory_boy superior to using the ORM directly in tests?
0๐
https://github.com/RueLaLa/savory-pie
Savory Pie is a REST framework that supports django.
- [Django]-Serializer call is showing an TypeError: Object of type 'ListSerializer' is not JSON serializable?
- [Django]-Whats the simplest and safest method to generate a API KEY and SECRET in Python
- [Django]-How to TRUNCATE TABLE using Django's ORM?
0๐
I would suggest you look into Django Rest Framework (DRF), play around with this and see if it suits your requirements. The reason I recommend DRF is because it makes making the API views really simple with the use of GenericAPIView classes, Mixin Classes and Mixed in Generic views. You can easily make use of tried and tested design patterns for making your API endpoints as well as keeping your code base neat and concise. You also DRY when writing your code which is always great. Your API views are literally 2-3 lines long.
You can checkout this tutorial http://programmathics.com/programming/python/django-rest-framework-setup/ that begins from setting up your environment to going through the different ways to make your RESTful API using the django rest framework.
Disclaimer: I am the creator of that website.
- [Django]-Django filter JSONField list of dicts
- [Django]-How to server HTTP/2 Protocol with django
- [Django]-Redis Python โ how to delete all keys according to a specific pattern In python, without python iterating