xadmin icon indicating copy to clipboard operation
xadmin copied to clipboard

How delete value from autocomplete field

Open mszpadzik opened this issue 12 years ago • 4 comments

Guys, I have problem - when I have foreign key in model, for which xadmin creates autocomplete choice field, when I choose something and save, I can't then delete value from that field. I can only change it to another choice from autocomplete list. But can't delete my choice to make it once again empty.

Does anybody have same problem ? How to fix it ?

mszpadzik avatar Jul 22 '14 21:07 mszpadzik

I think, that this widget doesn't support ForeignKey with null=True and blank=True. I'm trying to figure out how fix it, but help will be appreciated :)

mszpadzik avatar Jul 23 '14 13:07 mszpadzik

I think that possible are two solutions:

  1. First: add to choices list empty value, to let choose it or
  2. Add small "Clear" button near to widget, to clear selected choice

Still need help :)

mszpadzik avatar Jul 23 '14 13:07 mszpadzik

PS. There are two widgets for FKs: dropdown list field and search autocomplete list. Problem is with that autocomplete widget.

mszpadzik avatar Jul 24 '14 06:07 mszpadzik

Because I was unable to fix it, I changed widget for my FK field to xadmin.widgets.AdminSelectWidget, and for now it's fine for me.

You can close that ticket, but I think, that someone with bigger skills than mine, should fix it.

mszpadzik avatar Jul 25 '14 09:07 mszpadzik