Content-Type and Views

What general convention supports multiple views (e.g. html, json, xml) for resources (e.g. blog, user) in django?

First of all, I don’t know how to format my URLs. For example, what do you assume using any of these URLs to request xml format

  • /<resource>.<format>, eg. /blogs/123.xml
  • /<format>/<resource>, eg. /xml/blogs/123
  • /<resource>?format=<format>, eg. /blogs/123?format=xml

Should I just rely on the passed parameter Content-Type? How about having multiple mobile views (e.g. iphone, mobile, palm) and a full browser view?

What about the views? What is the convention for choosing the right patterns without if statements or multiple code.

+5
source share
1

, , :

  • Accept ( , ) , Accept.
  • , Request-URI, Accept.

URL- , , . , , Accept.

, :

GET /blogs/123.xml HTTP/1.1
Host: example.com

:

GET /blogs/123 HTTP/1.1
Host: example.com
Accept: application/xml

application/xml XML.

+7

All Articles