Django Slumber

Created 29th June, 2012 03:10 (UTC), last edited 10th April, 2015 05:19 (UTC)

Slumber is a RESTful data connector that can be used to make proper RESTful data services from Django systems.

  • Browse objects in your database
  • Add new objects, update and delete existing objects (using the normal Django permissions for security)
  • Log in users whose credentials are stored on a remote Slumber system
  • Easily add your own server side operations for implementing application logic
  • Be able to easily use a remote Slumber service from your Django code and test them
  • Configure remote Slumber services with only a single URL

Slumber is intended to help you build large complex REST based applications where you have multiple services that must communicate to implement a full system. Slumber is a perfect way to write the server side for your AngularJS application.

Slumber has two parts, the server and client sides. A RESTful service can be used by just adding the server side to an existing Django system. The client side is useful where you want to connect to the data service from another Python system, or even if you just want to decouple the persistence from the user interface layers within Django.

Installing Slumber

Slumber is available on pypi. To install it use:

pip install django-slumber

In order to start to use Slumber on the server side you simply need to include it in your urls.py with something like this:

url(r'^slumber/', include('slumber.urls'))

This is all you need to do to start to manage your data with Slumber. You can now visit the Slumber starting URL on your project via http://localhost:8000/slumber/. If everything is set up correctly you should see a list of the Django applications you've installed.

Understanding Slumber

Slumber is based around a single entry point, called the service directory. This is where you get to when you hit the main Slumber URL. Typically each service is a separate Django project running a part of a larger system. This service layer is however optional. Simple REST services won't require them.

The next layer down consists of the Django applications. Slumber will expose these automatically for you and relies on the Django permissioning system to control access.


Categories: