如何在Django中修复Form的CSS?

时间:2019-11-14 13:58:26

标签: django django-models bootstrap-4 django-forms django-views

大家好,如何纠正此错误,您可以在图像中看到我不想要此边框,但是我一次又一次得到此边框

错误:

enter image description here

我不希望后边框如何解决?

我正在使用Bootstarp

forms.py

class user_buy_form(forms.ModelForm):
    Terms_of_trade = forms.CharField(widget=forms.Textarea)
    class Meta:
        model = user_buy
        widgets = {
            'Currency':forms.Select(attrs={'class':'form-control currency','label':''}),
            'Bank_Name':forms.TextInput(attrs={'class':'form-control Bank-Name'}),
            'Min_transaction_limit':forms.TextInput(attrs={'class':'form-control Min-transaction-limit'}),
            'Max_transaction_limit':forms.TextInput(attrs={'class':'form-control Max-transaction-limit'}),
            'Terms_of_trade':forms.TextInput(attrs={'class':'form-control Terms-of-trade'}),
            'payment_method':forms.TextInput(attrs={'class':'form-control payment-method'}),
            'price':forms.TextInput(attrs={'class':'form-control price'}),
            'Location':forms.TextInput(attrs={'class':'form-control Location'}),
            'Trade_limits':forms.TextInput(attrs={'class':'form-control Trade-limits'}),
        }
        fields = '__all__'
        exclude = ('users',)

这是我的 html文件

<form class="form-control" method="POST">

    {% csrf_token %}
    {{usr_buy.as_p }}
    <input type="submit" class="btn btn-primary" value="Submit">
</form>

任何帮助都会得到赞赏

谢谢!

1 个答案:

答案 0 :(得分:1)

您需要将此表单控件的表单类更改为此表单

您可以用此表单替换表单,希望它可以正常工作:

<form class="form" method="POST">

    {% csrf_token %}
    {{usr_buy.as_p }}
    <input type="submit" class="btn btn-primary" value="Submit">
</form>