forms.py 1.23 KB
Newer Older
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
from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Field, HTML
from crispy_forms.bootstrap import PrependedText, AppendedText, FormActions

from accounts.models import Student

# form to create student
class StudentForm( forms.ModelForm ):

    def __init__(self, *args, **kwargs):

        self.helper = FormHelper()
        self.helper.layout = Layout(
            'user',
            PrependedText('room', 'Room'),
            'class',
            AppendedText('major', 'Major'),
        )
        self.helper.form_method = 'post'
        self.helper.add_input(Submit('submit', 'Submit'))

        super(StudentForm, self).__init__(*args, **kwargs)

    class Meta:
27
        model = Student
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

class UserSettingsForm( forms.ModelForm ):

    def __init__(self, *args, **kwargs):

        self.helper = FormHelper()
        self.helper.layout = Layout(
            'user',
            PrependedText('room', 'Room'),
            'class',
            AppendedText('major', 'Major'),
        )
        self.helper.form_method = 'post'
        self.helper.add_input(Submit('submit', 'Submit'))

        super(StudentForm, self).__init__(*args, **kwargs)

    class Meta:
        model = Student