Permalink
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (80 sloc) 3.43 KB

Tastypie Settings

This is a comprehensive list of the settings Tastypie recognizes.

API_LIMIT_PER_PAGE

Optional

This setting controls the default number of records Tastypie will show in a list view.

This is only used when a user does not specify a limit GET parameter and the Resource subclass has not overridden the number to be shown.

An example:

API_LIMIT_PER_PAGE = 50

If you don't want to limit the number of records by default, you can set this setting to 0:

API_LIMIT_PER_PAGE = 0

Defaults to 20.

TASTYPIE_FULL_DEBUG

Optional

This setting controls what the behavior is when an unhandled exception occurs.

If set to True and settings.DEBUG = True, the standard Django technical 500 is displayed.

If not set or set to False, Tastypie will return a serialized response. If settings.DEBUG is True, you'll get the actual exception message plus a traceback. If settings.DEBUG is False, Tastypie will call mail_admins() and provide a canned error message (which you can override with TASTYPIE_CANNED_ERROR) in the response.

An example:

TASTYPIE_FULL_DEBUG = True

Defaults to False.

TASTYPIE_CANNED_ERROR

Optional

This setting allows you to override the canned error response when an unhandled exception is raised and settings.DEBUG is False.

An example:

TASTYPIE_CANNED_ERROR = "Oops, we broke it!"

Defaults to "Sorry, this request could not be processed. Please try again later.".

TASTYPIE_ALLOW_MISSING_SLASH

Optional

This setting allows your URLs to be missing the final slash. Useful for integrating with other systems.

You must also have settings.APPEND_SLASH = False so that Django does not emit HTTP 302 redirects.

An example:

TASTYPIE_ALLOW_MISSING_SLASH = True

Defaults to False.

TASTYPIE_DATETIME_FORMATTING

Optional

This setting allows you to globally choose what format your datetime/date/time data will be formatted in. Valid options are iso-8601, iso-8601-strict & rfc-2822.

An example:

TASTYPIE_DATETIME_FORMATTING = 'rfc-2822'

Defaults to iso-8601. iso-8601 includes microseconds if available, use iso-8601-strict to strip them.

TASTYPIE_DEFAULT_FORMATS

Optional

This setting allows you to globally configure the list of allowed serialization formats for your entire site.

An example:

TASTYPIE_DEFAULT_FORMATS = ['json', 'xml']

Defaults to ['json', 'xml', 'yaml', 'plist'].

TASTYPIE_ABSTRACT_APIKEY

Optional

This setting makes the ApiKey model an abstract base class. This may be useful in multi-database setups where many databases each have their own table for user data and ApiKeyAuthentication is not used. Without this setting, the tastypie_apikey table would have to be created on each database containing user account data (such as Django's built-in auth_user table generated by django.contrib.auth.models.User). Valid options are True & False.

An example:

TASTYPIE_ABSTRACT_APIKEY = True

Defaults to False.