File: debugging.rst

package info (click to toggle)
django-tastypie 0.9.10-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,020 kB
  • sloc: python: 6,530; makefile: 78; sh: 45
file content (29 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. ref-debugging:

==================
Debugging Tastypie
==================

There are some common problems people run into when using Tastypie for the first
time. Some of the common problems and things to try appear below.


"I'm getting XML output in my browser but I want JSON output!"
==============================================================

This is actually not a bug and JSON support is present in your ``Resource``.
This issue is that Tastypie respects the ``Accept`` header your browser sends.
Most browsers send something like::

    Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Note that ``application/xml`` comes first, which is a format that Tastypie
handles by default, hence why you receive XML.

If you use ``curl`` from the command line, you should receive JSON by default::

    curl http://localhost:8000/api/v1/

If you want JSON in the browser, simply append ``?format=json`` to your URL.
Tastypie always respects this override first, before it falls back to the
``Accept`` header.