1👍
✅
Instead of using a CharField
to store the id, try using a ModelChoiceField
with the widget set as a HiddenInput
. The field definition in your form would look something like:
mymodel = forms.ModelChoiceField(widget=forms.HiddenInput, queryset=MyModel.objects.all())
Source:stackexchange.com