modelchoicefield

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

Select a valid choice. That choice is not one of the available choices

只愿长相守 提交于 2020-12-30 03:42:05
问题 In my app, i have a dropdown (department) that's depending on the previously selected value from a dropdown(faculty field). I am using ajax to get the new value which works fine. However, when i try saving the form, i get Select a valid choice. That choice is not one of the available choices. Here is my model from django.db import models from system.models import FacultyData, DepartmentData, SessionData, SemesterData, SettingsData # Create your models here. class SchoolFees(models.Model): fid

Select a valid choice. That choice is not one of the available choices

戏子无情 提交于 2020-12-30 03:39:45
问题 In my app, i have a dropdown (department) that's depending on the previously selected value from a dropdown(faculty field). I am using ajax to get the new value which works fine. However, when i try saving the form, i get Select a valid choice. That choice is not one of the available choices. Here is my model from django.db import models from system.models import FacultyData, DepartmentData, SessionData, SemesterData, SettingsData # Create your models here. class SchoolFees(models.Model): fid