A resource represents an object, typically a Django model instance. Using the REST shortcut, list and detail resources are automatically created for the relevant models.

You can manually register a resource for a model like this:

from api.resources import registry
from todos.models import Task


This will create TaskResource and TaskResourceList classes at runtime.

You can also define your own resources, and register them like so:

from api.resources import ModelResource, ModelResourceList
from todos.models import Task

class TaskResource(ModelResource):
    model = Task

class TaskResourceList(ModelResourceList):
    model = Task

registry.register(Task, TaskResourceList, TaskResource)

API reference