[Fixed]-Django. How to create django_easyselect_form with custom fieldset?

0👍

I’ve decided not to use model form and created simple form with necessary widgets:

class SendTransferForm(forms.Form):
    sender = forms.ModelChoiceField(queryset=BankAccount.objects.all(), widget=Select2(), label="Счёт отправителя")
    receiver = forms.ModelChoiceField(queryset=BankAccount.objects.all(), widget=Select2(), label="Счёт получателя")
    total = forms.CharField(widget=forms.TextInput(attrs={'class': 'select2fake'}), label="Сумма")
    comment = forms.CharField(widget=forms.TextInput(attrs={'class': 'select2fake'}), label="Комментарий")

1👍

You can create two forms class

class FirstForm(ModelForm):
    class META:
        model = models.MoneyTransfer
        fields = ['receiver', 'comment', 'total']

and then:

class SecondForm(ModelForm):
    class META:
        model = models.MoneyTransfer
        fields = ['sender', 'receiver', 'comment', 'total']

Leave a comment