Replies: 2 comments
-
Hi @lgimberis, Thanks for reaching out. This is a somewhat unique use case, but not impossible. If you have a look at the inheritance graph here, you can see how the tag widget inherits from a multiple select input. https://django-select2.readthedocs.io/en/latest/django_select2.html#module-django_select2.forms However, if you look at the corresponding code, it should be fairly simple to recreate the same for a single select input. If you need further assistance, I can go into more detail. Best Joe |
Beta Was this translation helpful? Give feedback.
-
Hi, I wonder to share my solution for a single tag selection/creation widget.
|
Beta Was this translation helpful? Give feedback.
-
Hi, firstly thanks for your work on this project. It's exactly what I was looking for.
I'm currently trying to implement a select2 field that allows the end user to either select an existing value OR enter a 'new' value, which will automatically create the related object. It seems that the ModelSelect2TagWidget was made for exactly this purpose.
However, this widget inherently allows selecting multiple items at once. In the context where I'm using it, this isn't appropriate and the user should only be able to enter a single value.
Is there a straightforward way to configure a ModelSelect2TagWidget to only select a single item, or ModelSelect2Widget to allow 'tagging'/submission of items that don't yet exist?
To clarify, something more like the first example on this page, currently it's the second.
Right now, the best way I can see to achieve this would be to make a custom set of widgets parallel to the existing tag widgets but without the multiple mixin - is there a simpler way?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions