Skip to content

Instantly share code, notes, and snippets.

@mrchilds
Created July 6, 2012 16:25
Show Gist options
  • Save mrchilds/3061165 to your computer and use it in GitHub Desktop.
Save mrchilds/3061165 to your computer and use it in GitHub Desktop.
Django - basic ajax
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.utils import simplejson
def myajax(request):
#Some logic
html = render_to_string(TEMPLATE, context)
return HttpResponse(simplejson.dumps({"html": html}),
content_type="application/json; charset=utf-8")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment