1👍
✅
The traceback is telling you that the problem is this line in your UnidadesForm
model form.
ciudad = forms.ModelChoiceField(widget=forms.Select(attrs={'size':'13', 'onchange':'this.form.action=this.form.submit()'}), choices= RefCiudades.objects.filter(provincia__contains = RefProvincia.objects.filter(descripcion__contains = "CHUBUT").values("id")) )
As it’s a model choice field, it would be better to use the queryset
argument rather than choices
.
ciudad = forms.ModelChoiceField(widget=forms.Select(attrs={'size':'13', 'onchange':'this.form.action=this.form.submit()'}), queryset= RefCiudades.objects.filter(provincia__contains = RefProvincia.objects.filter(descripcion__contains = "CHUBUT").values("id")) )
I think that might stop the error, but I’m not sure that your queryset makes sense. The filter argument provincia__contains
should take a string, but RefProvincia(...).values("id")
will return a values queryset.
Source:stackexchange.com