django-multiselectfield icon indicating copy to clipboard operation
django-multiselectfield copied to clipboard

How do you even add/remove a value?

Open kpagcha opened this issue 5 years ago • 1 comments

I expected some kind of interaction with the field to add and remove values manually. However it just returns a string... How am I even able to instance.multiselectfield.add(value)? It just seems to behave like a normal text field.

kpagcha avatar Feb 21 '20 12:02 kpagcha

@kpagcha You cant, you have to assign a new list of the values you intend the field to have, like so:

object.achievements = ['newbie', 'verteran']
object.save()

I had to spend at least an hour to figure this out

martyglaubitz avatar Jun 01 '22 09:06 martyglaubitz

Correct, you can't, you just have to overwrite the list. This package is a bit of a hack, and sometimes M2M fields make more sense for your application.

blag avatar May 24 '24 19:05 blag