def new_forum(request): form = ForumForm() if request.method == 'POST': form = ForumForm(request.POST) if form.is_valid(): forum = Forum() forum.slug = form.cleaned_data['slug'] forum.description = form.cleaned_data['description'] forum.creator = request.user forum.save() return HttpResponseRedirect(reverse('forum:forum-home', )) context = get_base_context() context['form'] = form return render(request, 'forum/new-forum.html', context)
def new_forum(request): form = ForumForm() if request.method == 'POST': form = ForumForm(request.POST) if form.is_valid(): forum = Forum() forum.title = form.cleaned_data['title'] forum.description = form.cleaned_data['description'] forum.creator = request.user forum.save() return HttpResponseRedirect(reverse('forum:forum-index')) return render( request, 'forum/new-forum.html', {'form': form}, )