render_to_json

1
2
3
4
5
6
7
8
9
frm django.shortcuts import render_to_response

def render_to_json(*args, **kwargs):
    response = render_to_response(*args, **kwargs)
    response['mimetype'] = "text/javascript"
    response['Pragma'] = "no cache"
    response['Cache-Control'] = "no-cache, must-revalidate"

    return response

More like this

  1. Template filters utils by marinho 5 years, 6 months ago
  2. Admin list_display Ajax by whiteinge 5 years, 3 months ago
  3. Generic csv export admin action by dek 3 years, 9 months ago
  4. Bind Administration by ashcrow 4 years, 8 months ago
  5. Export Related as JSON Admin Action by johnboxall 3 years, 10 months ago

Comments

kcarnold (on February 28, 2008):

JSON doesn't necessarily mean no cache. Don't blindly copy-paste; think about if your data can be cached.

#

(Forgotten your password?)