I am migrating an existing API from Django Piston to Django Tastypie. I am using Django 1.7.
The existing API outputs JSON by default, but supports XML queries if ?format=xml
is appended to the URL.
I am finding it hard to work out how to replicate this in Tastypie. There's a very similar question here, but all the answers only explain how to totally disable all other formats except JSON. So I'm wondering if it's actually possible to do this in Tastypie.
If I do this in my settings file:
TASTYPIE_DEFAULT_FORMATS = ['json']
JSON becomes the default, but I can't then output XML with a ?format=xml
parameter, because XML is disabled.
Similarly if I add a determine_format
method to the resource.
Is it possible to specify JSON as the default format, but also allow XML?
meta
class? See: django-tastypie.readthedocs.org/en/latest/serialization.html - kchan