ajax_form_view

1
2
3
4
5
6
7
8
@ajax_request
def add_comment(request, id):
author = request.user
blog = Blog.objects.get(pk=id)
content = request.POST['content']
date = datetime.datetime.now()
Comment.objects.create(author=author, blog=blog, content=content, date=date)
return {'author': author, 'content': content, 'date': date}