コード例 #1
0
ファイル: views.py プロジェクト: hydrospanner/DForurm
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)
コード例 #2
0
ファイル: views.py プロジェクト: exploit97/SchooliEducation
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},
    )