hello, my select2 component is working, it brings all consumers, but I would like to know if I can filter these consumers according to the logged in user. How to change a query?
Here’s my form code.
class ConsumidorWidget(s2forms.ModelSelect2Widget):
search_fields = [
"nome__icontains",
"email__icontains",
]
class ConsumoForm(forms.ModelForm):
class Meta:
model = Consumo
fields = ('id', 'consumidor', 'mesconsumo', 'anoconsumo', 'valorapagar', 'valorhidrometro',
'dataleitura', 'datamissao', 'datavencimento', 'foipago',)
exclude = ('bairro',)
mesconsumo = forms.ChoiceField()
# widgets = {
# 'data_pagamento': DateInput(),
# }
widgets = {
"consumidor": ConsumidorWidget,
}