REST handler managed by way of a decorator
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Don't Use This

This was written years ago, back when django-piston was a thing, and suites like tastypie and django-rest-framework didn't exist. Now that these projects are around though, this code is stagnant and lacking in the support and features you'll find in those projects, so go use them instead.


Requires: oauth2 django

Here's an example to get you started:

from django_rest.views import RestView from django_rest.decorators import restrict_methods

class View(RestView): """ Exceptions thrown are handled higher up the stack by returning handy things like Http404 """

def access(self):
	if self.request.method == "POST":
		return self._access_post()
	elif self.request.method == "PUT":
		return self._access_put()

def _access_post(self):

	name = self.request.DATA.get("name")
	prod = Product.object.create(name=name)
	return self.CREATED(

def _access_put(self):

	id   = self.request.DATA["id"]
	name = self.request.DATA["name"]

	prod = Product.object.get(pk=id) = name

	return self.UPDATED()

from django.conf.urls.defaults import * from product.views import View as ProductView


urlpatterns = patterns("", url(r"^$", ProductView(), {"__method": "access"}, name="product-api"), )