Repository navigation
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 |
0 replies
|
Hi, I wonder to share my solution for a single tag selection/creation widget. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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.
All reactions