Closed raratiru closed 1 year ago
The code that determines which field to use as an "ID" is still fairly primitive - it sounds like the default primary key field in this case is not appropriate? I don't see the Partner model definition but you can override the field by setting item_value
like this:
class FeedForm(forms.ModelForm):
class Meta:
model = models.Feed
fields = "__all__"
widgets = {
'partner_key': widgets.Autocomplete(
name='partner_key',
options=dict(
multiselect=False,
model=Partner,
item_value='partner_id_or_whatever',
)
)
}
If you can share the Partner model's class I can investigate further - an possibly improve the code that determines which field to use...
Oh I see, thank you!
The Partner
model has only a name
attribute. I will give it a try and then I will close the issue.
It is very possible that it will work.
Having implemented the example with the modelform, when I click on a result to select it, I receive a 500 error:
ValueError: Field 'id' expected a number but got ''.
This is a ForeignKey to another app and I use
to
to avoid circular dependency error. Could this be the issue?models.py:
forms.py:
This is the complete stack: