django-select2

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

时光毁灭记忆、已成空白 提交于 2021-01-29 15:25:43
问题 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), widget=Select2(select2attrs={"width": "400px"}), ) as you can see, I am using the easy_select2 module, that is enabling providing me with a look up field too. However, if I try to load this in the corresponding tabularInLine, it never loads because there is a

django_select2 - limit the returned text to a specific field in module

狂风中的少年 提交于 2021-01-29 14:39:09
问题 I am using django_select2 in my application. I would like to search and display only according to one field of a model. models.py: class Venue(models.Model): venue_name = models.CharField(max_length=50) venue_city = models.CharField(max_length=50) venue_country = models.CharField(max_length=50) def __str__(self): return f"{self.venue_name}, {self.venue_city}, {self.venue_country}" forms.py: from django import forms from .models import from django_select2 import forms as s2forms class

Django select2 chained dropdown with elasticsearch

风格不统一 提交于 2019-12-13 04:26:46
问题 I would like to have a chained dropdown with elasticsearch as back end using Django. I have two indices in ES and I will use index A for the chained dropdown and index B for the search given contraints selected in index A using common fields. Like below where after selecting Lv0, Lv1 will be populated depending on the values selected in Lv0. After clicking submit form(I hope this can pass the selected variables to index B for query), query can be made over index B in selected Lv0 and Lv1 only