Questions tagged [django-select2]

Select2 jQuery plugin wrapped to Django Widget

This is a Django integration of Select2.

The app includes Select2 driven Django Widgets.

Select2 is already included to the distribution.

External Dependencies:

jQuery is not included in the package since it is expected that in most scenarios this would already be available.

https://django-select2.readthedocs.io/en/latest/ https://github.com/applegrew/django-select2

64 questions
0
votes
1 answer

How to send the text in django-select2 field instead of the id at form submission?

This is a two-part question Problem description I have a form with a field that uses ModelSelect2TagWidget (that accepts free-text as an input). when the user enters a number as free-text, it is converted to the object whose id is the number entered…
0
votes
1 answer

How do I use a select2 multiple select in a django crispy form?

I have an existing crispy form. I want to use django-select2 to replace an existing multi-select with a Select2 field with a maximum of two selections. I know from this post that I need to include 'data-maximum-selection-length' as a widget…
0
votes
1 answer

How to add a searchable text field to select an item in drop down list?

I have a filter form as you can see https://jsfiddle.net/aba2s/qcsynt7f/6/. I would like to add a searchable field(in the red area) so users can filter the campaign naming tool object instead of scrolling. Any help is appreciated. My filter…
0
votes
1 answer

Select2 widget showing on Django Admin site but not on the form template in Django4

I have two object models, NewsObject and StockObject. The stock object is a foreign key in the news object. class stockObject(models.Model): stock_name = CharField(max_length=100, blank=True, null=True) stock_tag = CharField(max_length=100,…
0
votes
0 answers

I cannot set a value to django-select2 ModelSelect2Widget using val() function

In my django app I have a CenterModel and a ProvinceModel, each center has a province_id field. I have define a form for Center using ModelSelect2Widget (django_select2) for province_id. I want to set the selected value to the province_id field in…
Ernesto Ruiz
  • 736
  • 9
  • 31
0
votes
1 answer

Django form doesn't validate when init ModelMultipleChoiceField without data

I want to use ModelMultipleChoiceField with select2 in my Django application. this is forms.py : #forms.py class SymbolForm(forms.Form): symbol = forms.ModelMultipleChoiceField(queryset=Symbol.objects.all(), label='symbol') Everything is ok…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

How to debug django-select2 dropdown

I like to create a text search field based on dropdown options from a model. I chose django-select2 but it isn't working. This is the output HTML

Issue Book



fakeMake
  • 738
  • 8
  • 18
0
votes
1 answer

How to set value to django-select2 field Programmatically (on button click) using javascipt?

In my django app I have a WorkerModel and a ProvinceModel, each worker has a province_id field. I have define a form for Worker using ModelSelect2Widget (django_select2) for province_id. I want to know how to set a value to province_id field using…
Ernesto Ruiz
  • 736
  • 9
  • 31
0
votes
0 answers

Select2 Issue with backend as '\t' save into database, how to fix it?

I am trying to save multiple select dropdown data into my database and i am using select2 class for the same, but in my backend the data save in format like ['\tdataname1\t', '\tdataname2\t']. i want to fix it and save data as 'dataname1',…
0
votes
1 answer

Error -Undefined variable: 'ModelSelect2Widget'

I am new to this field. I am working on Dependent Dropdowns for which i took reference from here. On replicating the same with the following code: Forms.py class AddressForm(forms.ModelForm): class Meta: model=City country =…
Ritu
  • 1
  • 1
0
votes
1 answer

Django admin tabular inline lookup select dropdown box for a very large queryset

I have a django admin tabular inline, in which I have form = ProdForm which holds a modelchoicefield select box as follows; class ProdForm(forms.ModelForm): productid = forms.ModelChoiceField(queryset=Product.objects.filter(active=True), …
0
votes
2 answers

django-select2 store multiple selection

What is the correct way of saving multiple selections selected from Django-select2 Widget? this is my model class Rgn_Details(models.Model): request_no = models.ForeignKey(Request_Flow, on_delete=models.CASCADE, related_name='request_ref') …
Praveen
  • 346
  • 1
  • 6
  • 18
0
votes
0 answers

why do I get this error django_select2.js was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type

I'm trying to make the select2 work in my django app via django_select2 library. I've done the installation of the library, setup in URL and the change required in the forms.py. I have also added {{ form.media.css }} and {{ form.media.js }}. When I…
chip
  • 3,039
  • 5
  • 35
  • 59
0
votes
2 answers

Django select2, show subcategories when parent category name searched

I used django-select2 to show parent categories and sub categories. When I search the name of parent category using 'Select2MultipleWidget' (Pacific Time Zone, for example), it does not show its sub categories. Is it possible to show belonging sub…
user3422616
  • 23
  • 1
  • 5
0
votes
1 answer

Django-select2 selects pk (IntegerField) instead of username (CharField)

My goal is to create a form to add a rental for a device including a user. device and user are implemented with a ForeignKey, and for the user i want to use django-select2 , because of the heavy amount of users. models.py class…
fuser60596
  • 1,087
  • 1
  • 12
  • 26