def newthread2 request form CreateThreadForm request POST if form is_v

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def newthread2(request):
form = CreateThreadForm(request.POST)
if form.is_valid():
title = request.POST.get('subject', False)
body = request.POST.get('message', False)
fid = request.POST.get('forum', False)
f = get_object_or_404(Forum, id=fid)
t = Thread(
forum=f,
title=title,
)
t.save()
class CreateThreadForm(forms.Form):
subject = forms.CharField(label=u'Тема новой записи')
forum = forms.ModelChoiceField(label=u'Раздел форума', queryset=Forum.objects.exclude(slug__in=(settings.COMMENT_FORUM_SLUG, settings.BLOG_COMMENT_SLUG)).order_by('pos'))
message = forms.CharField(label=u'Сообщение')