Question

i have a class named cv,and a class named university, and each user that completes his cv, should choose a University he studyes at.

My problem is: one student can study at one or 2 or three universities, or may be a user that is not student.

I need to take this data into a form, and i use ModelForm. The data from the Cv class, and from the University class in the same form, and the user can add one or more universities, or no university. (in the same form)

How should i do it? Should i use ModelForm? if i have a foreign key in the CV class, and the user is not a student (so he is at zero universities), i may get an referencial integrity error.

thanks a lot

Was it helpful?

Solution

ModelForms will display your ManyToManyFields (that's the correct type for your university field in your Cv class) as multipe-select widget.

If you prefer checkboxes, use the forms.CheckboxSelectMultiple widget for this field in your form class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top