Skip to content

Instantly share code, notes, and snippets.

@grobertson
Created May 6, 2013 16:34
Show Gist options
  • Save grobertson/5526259 to your computer and use it in GitHub Desktop.
Save grobertson/5526259 to your computer and use it in GitHub Desktop.
def article_social_history(request, slug, section_slug):
article = DDArticle.published_objects.get(primary_section__slug=section_slug, slug=slug)
h = article.get_social_history()
history = []
for record in h:
for k, v in record.items():
if hasattr(v, 'isoformat'):
record[k] = v.isoformat()
history.append(record)
json_data = json.dumps(history)
return HttpResponse(json_data, mimetype='application/json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment