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']
- AttributeError / object has no attribute 'cleaned_data'
- Django URL Error in Azure web app
- Problems with TabularInline in Django Admin
- Django unable to redirect when link is clicked
Source:stackexchange.com