class StudentForm(ModelForm):
+
+ def has_changed(self):
+ """
+ Overriding this, as the initial data passed to the form does not get noticed,
+ and so does not get saved, unless it actually changes
+ """
+ changed_data = super(ModelForm, self).has_changed()
+ return bool(self.initial or changed_data)
+
class Meta:
model = Student
exclude = ['user', 'trainings', 'options']
fields = ['iej', 'period', 'procedure', 'written_speciality', 'oral_speciality',
'oral_1', ]
- def get_initial(self):
- initial = super(StudentInline, self).get_initial()
- initial['procedure'] = Course.objects.filter(title__contains='civil')
- return initial
user.save()
return super(UserAddView, self).forms_valid(form, inlines)
+ #def construct_inlines(self):
+ #Filtra el socio de negocio del detalle por tipo=Proveedor (Aseguradora)
+ # inlines = super(CreateWithInlinesView, self).construct_inlines()
+ # student_inline = inlines[1]
+ # student_inline.form.base_fields['procedure'].queryset = Course.objects.filter(title__contains='civil')
+ # return inlines
+
class UserCompleteView(TemplateView):