Closed
Description
We are using AutoModelSelect2Field like that:
from django_select2.fields import AutoModelSelect2Field
class EmployeeChoices(AutoModelSelect2Field):
search_fields = ('last_name__icontains', 'first_name__icontains')
def get_queryset(self):
current_site = Site.objects.get_current()
return User.objects.of_site(current_site).employees()
def set_queryset(self, queryset):
pass
queryset = property(get_queryset, set_queryset)
class TicketForm(forms.ModelForm):
employee = EmployeeChoices(label=_('Employee'), required=False)
class Meta:
model = Ticket
fields = ('employee', 'subject', 'body', 'priority')
But when we load the ModelForm with an instance, the employee field is empty instead of containing the instance value.
Do you have any idea what's wrong?
It could be very nice to be able to define get_queryset() without having to use this awkward trick.
Metadata
Metadata
Assignees
Labels
No labels