def _edit_post(request, obj): if request.method == 'POST': form = BlogPostForm(request.POST, instance=obj) if form.is_valid(): form.save() return HttpResponseRedirect(obj.get_absolute_url()) else: form = BlogPostForm(instance=obj) return render_to_response('blog/post_add.html', RequestContext( request, {'form': form, 'object': obj, 'group': obj.group }))
def _new_post(request, group): if request.method == 'POST': form = BlogPostForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.slug = slugify(post.title)[:50] post.publish = datetime.datetime.now() post.group = group post.save() return HttpResponseRedirect(post.get_absolute_url()) else: form = BlogPostForm() return render_to_response('blog/post_add.html', RequestContext( request, {'form': form, 'group': group }))
def _edit_post(request, obj): if request.method == 'POST': form = BlogPostForm(request.POST, instance=obj) if form.is_valid(): form.save() return HttpResponseRedirect(obj.get_absolute_url()) else: form = BlogPostForm(instance=obj) return render_to_response( 'blog/post_add.html', RequestContext(request, { 'form': form, 'object': obj, 'group': obj.group }))
def _new_post(request, group): if request.method == 'POST': form = BlogPostForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.slug = slugify(post.title)[:50] post.publish = datetime.datetime.now() post.group = group post.save() return HttpResponseRedirect(post.get_absolute_url()) else: form = BlogPostForm() return render_to_response( 'blog/post_add.html', RequestContext(request, { 'form': form, 'group': group }))