mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from django import forms
|
|
from bootcamp.questions.models import Question, Answer
|
|
|
|
|
|
class QuestionForm(forms.ModelForm):
|
|
title = forms.CharField(
|
|
widget=forms.TextInput(attrs={'class': 'form-control'}),
|
|
max_length=255)
|
|
description = forms.CharField(
|
|
widget=forms.Textarea(attrs={'class': 'form-control'}),
|
|
max_length=2000)
|
|
tags = forms.CharField(
|
|
widget=forms.TextInput(attrs={'class': 'form-control'}),
|
|
max_length=255,
|
|
required=False,
|
|
help_text='Use spaces to separate the tags, such as "asp.net mvc5 javascript"')
|
|
|
|
class Meta:
|
|
model = Question
|
|
fields = ['title', 'description', 'tags']
|
|
|
|
|
|
class AnswerForm(forms.ModelForm):
|
|
question = forms.ModelChoiceField(widget=forms.HiddenInput(),
|
|
queryset=Question.objects.all())
|
|
description = forms.CharField(
|
|
widget=forms.Textarea(attrs={'class': 'form-control', 'rows': '4'}),
|
|
max_length=2000)
|
|
|
|
class Meta:
|
|
model = Answer
|
|
fields = ['question', 'description']
|