I've been looking into Django more. I was wondering the best way to automatically return the correct response format for any given type of request. Specifically, I'm interested in distinguishing between html and json requests.

In the past I've just appended '/json' to a given url to get json data, but then I was curious how Rails seems to automatically know what the request format was. According to this:

http://stackoverflow.com/questions/6253826/how-does-rails-determine-incoming-request-format

"Rails determines the desired response format from the HTTP Accept header submitted by the client."

It looks like there is similar functionality in Django, but the routing is not as built in as in Rails.

From:
http://stackoverflow.com/questions/9262278/django-view-returning-json-without-using-template

You can use request.is_ajax(). But that requires that the HTTP_X_REQUESTED_WITH header is set. Most JavaScript libraries do this automatically, but if you're using some other type of client, you'll need to make sure it sets it as well. Alternatively, you can pass a querystring such as ?json with the URL and then check request.GET.has_key('json'), which is probably a little more foolproof.

More details are available here:
https://docs.djangoproject.com/en/dev/ref/request-response/

http://www.google.com/search?hl=en&client=firefox-a&channel=s&rls=org.mozilla%3Aen-US%3Aofficial&hs=bk1&q=python+web+framework&btnG=Search
python web framework - Google Search
http://pinaxproject.com/
Pinax
http://cloud27.com/
Cloud27 : Welcome
http://jtauber.com/blog/2008/05/10/introducing_pinax/
James Tauber : Introducing Pinax
http://pinaxproject.com/docs/
Pinax : Documentation
http://pinaxproject.com/docs/0.5.1/intro.html
Introduction — Pinax v0.5.1 documentation
http://pinaxproject.com/download/
Pinax : Download
http://www.google.com/search?q=django&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
django - Google Search
http://www.djangoproject.com/
Django | The Web framework for perfectionists with deadlines
http://www.google.com/search?q=+django+sqlalchemy&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
django sqlalchemy - Google Search
http://code.google.com/p/django-sqlalchemy/
django-sqlalchemy - Google Code
http://lethain.com/entry/2008/jul/23/replacing-django-s-orm-with-sqlalchemy/
Replacing Django's ORM with SQLAlchemy @ Irrational Exuberance
http://bitbucket.org/context/context/overview/
context / context / overview — bitbucket.org
http://www.google.com/search?q=+django+vs+pylons&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
django vs pylons - Google Search
http://versus.bix.yahoo.com/vs/Django-vs-Pylons
Versus: Django vs. Pylons
http://thinkhole.org/wp/category/pylons/
import this. » Pylons
http://carefulweb.com/blog/2008/08/11/django-vs-pylons-development-and-deployment/
Careful Web: Django vs. Pylons
http://en.wikipedia.org/wiki/Invisible_hand
Invisible hand - Wikipedia, the free encyclopedia
http://byteflow.su/
Byteflow - a Python/Django Blog Engine
http://www.b-list.org/
The B-List
http://www.b-list.org/weblog/2007/feb/19/python-framework-design/
Python framework design
http://www.b-list.org/weblog/2006/oct/21/django-and-nih/
Django and NIH