1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
from django import forms
from website.models import *
#from spoken_auth.models import TutorialDetails
from django.db.models import Q
class NewQuestionForm(forms.ModelForm):
category = forms.ModelChoiceField(widget = forms.Select(attrs = {}),
queryset = FossCategory.objects.order_by('name'),
empty_label = "Select a category",
required = True,
error_messages = {'required':'Select a category.'})
title = forms.CharField(widget=forms.TextInput(),
required = True,
error_messages = {'required':'Title field required.'})
body = forms.CharField(widget=forms.Textarea(),
required = True,
error_messages = {'required':'question field required.'}
)
class Meta:
model = Question
fields = ['category', 'title', 'body']
def __init__(self, *args, **kwargs):
category = kwargs.pop('category', None)
super(NewQuestionForm, self).__init__(*args, **kwargs)
class AnswerQuestionForm(forms.ModelForm):
question = forms.IntegerField(widget=forms.HiddenInput())
body = forms.CharField(widget=forms.Textarea(),
required = True,
error_messages = {'required':'Answer field required.'}
)
class Meta:
model = Question
fields = ['question', 'body']
class AnswerCommentForm(forms.Form):
body = forms.CharField(widget=forms.Textarea(),required = True,)
|