Exesize
1from django import forms2
3from mainapp.models import CourseFeedback4
5
6class CourseFeedbackForm(forms.ModelForm):7
8class Meta:9model = CourseFeedback10fields = ['course', 'user', 'rating', 'feedback']11widgets = {12'course': forms.HiddenInput(),13'user': forms.HiddenInput(),14# 'rating': forms.RadioSelect(),15}16
17def __init__(self, *args, course=None, user=None, **kwargs):18super().__init__(*args, **kwargs)19if course and user:20self.fields['course'].initial = course.pk21self.fields['user'].initial = user.pk22
23
24
25
26
27
28