Skip to main content

Django users RESTful API using Tastypie.

Project description

Django users RESTful API using Tastypie. This django app provides RESTful interface to:


pip install django-users-api

or from cloned repo

python install


Run tests:

$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements.txt
$ python test


You can integrate django-users-api app within your django app in various ways.

URLConfig (default)

Add django-users-api default urls to your projects urls. In the following example, we will include our users_api.urls prefixed with ‘auth/’.

In project

from django.conf.urls import patterns, include, url

urlpatterns = patterns(
    # ...,
    url(r'^auth/', include('users_api.urls')),
    # ...

The users_api URLs will be accessible via:


Selected Resources

In some cases you might need to exclude some resources from your project urls. In this case you will have to add the required resource(s) yourself.

Assuming you only require the UsersResource to be available (i.e. excluding GroupsResource & PermissionsResource)

In project

from django.conf.urls import patterns, include, url

from users_api.common import UsersApi
from users_api.api.users import UsersResource

django_users_api = UsersApi()

urlpatterns = patterns(
    # ...
    url(r'', include(django_users_api.urls)),
    # ...

The UsersResource url will be accessible via:




A tastypie ModelResource for django.contrib.auth.models.User.


  • List all users: /users/
  • List user 1: /users/1/

User JSON response example:

    "dateJoined": "2014-12-24T13:04:36",
    "email": "",
    "firstName": "",
    "isActive": true,
    "isStaff": true,
    "isSuperuser": true,
    "lastLogin": "2015-01-03T14:19:41.060600",
    "lastName": "",
    "resourceUri": "/users/1/",
    "username": "admin"


  • Create new user: /users/

Important: Creating user requires a password field to be submitted with data.

User JSON request payload example:

    "email": "",
    "firstName": "New",
    "lastName": "User",
    "username": "new_user"
    "password": "us3rP@sswd"


  • Update existing user: /users/1/

Submitting password field will change the user password.


  • Delete existing user: /users/2/


A tastypie ModelResource for django.contrib.auth.models.Group.


  • List all groups: /groups/
  • List group 1: /groups/1/
  • List user 1 groups: /users/1/groups/

Group JSON response example:

    "name": "Group name",
    "resourceUri": "/groups/1/"


  • Create new group: /groups/

Group JSON request payload example:

    "name": "HR Group"


  • Update existing group: /groups/1/
  • Assign group 1 to user 1: /users/1/groups/1/


  • Delete existing group: /groups/2/
  • Remove group 1 from user 1: /users/1/groups/1/


A tastypie ModelResource for django.contrib.auth.models.Permission.


  • List all permissions: /permissions/
  • List permission 1: /permissions/1/
  • List user 1 permissions: /users/1/permissions/
  • List group 1 permissions: /groups/1/permissions/

Permission JSON response example:

    "codename": "add_logentry",
    "contentTypeUri": "/contenttypes/1/",
    "name": "Can add log entry",
    "resourceUri": "/permissions/1/"


  • Create new permission: /permissions/

Important: A valid permission should reference a valid ContentType via contentTypeUri field (see ContentTypesResource).

Permission JSON request payload example (assuming we have a Blog model):

    "codename": "add_blog",
    "contentTypeUri": "/contenttypes/20/",
    "name": "Can add new blog",


  • Update existing permission: /permissions/1/
  • Assign permission 1 to user 1: /users/1/permissions/1/
  • Assign permission 1 to group 1: /groups/1/permissions/1/


  • Delete existing permission: /permissions/2/
  • Remove permission 1 from user 1: /users/1/permissions/1/
  • Remove permission 1 from group 1: /groups/1/permissions/1/


A Read-only tastypie ModelResource for django.contrib.auth.models.ContentType.


  • List all contenttypes: /contenttypes/
  • List contenttype 1: /contenttypes/1/

ContentType JSON response example:

    "appLabel": "admin",
    "model": "logentry",
    "name": "log entry",
    "resourceUri": "/contenttypes/1/"


By default, all resources use Tastypie SessionAuthentication.


By default, all resources use Tastypie DjangoAuthorization.

Important: DjangoAuthorization gives Read access to all users, which might not be the desired behavior.


Django-users-api resources are based on Tastypie ModelResource class, which gives you the ability to extend and override any of the users_api resources.


MIT License.

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-users-api, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django-users-api-0.1.tar.gz (11.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page