def edit(request): pk = request.POST.get('id') post = get_object_or_404(smodels.Post.objects.get_user_query_set(request.user), pk=pk) form = PostForm(request.POST, request=request, instance=post) if form.is_valid(): post = form.save() return {'preview': sanitize(post.text)} return form.errors
def edit(request): pk = request.POST.get('id') post = get_object_or_404(smodels.Post.objects.get_user_query_set( request.user), pk=pk) form = PostForm(request.POST, request=request, instance=post) if form.is_valid(): post = form.save() return {'preview': sanitize(post.text)} return form.errors
def preview(request): return {'preview': sanitize(request.POST.get('text', ''))}