2

I'm trying to change the ugly input type="file" to a more stylish bootstrap button. I tried to modify the widget giving him attrs of class btn btn-lg btn-primary but it gives some weird styling. I appreciate if there's a solution without using django-crispy-forms.

class CreateProductForm(forms.ModelForm):
    class Meta:
        model = Product

    def __init__(self, *args, **kwargs):
        super(CreateProductForm, self).__init__(*args, **kwargs)
        self.fields['picture'] = forms.ImageField(u'imagen', widget=forms.ClearableFileInput(attrs={'class':'btn btn-lg btn-primary'}))
akirashimosoeda
  • 99
  • 2
  • 11

1 Answers1

0

i think the problem is 'class':'btn btn-lg btn-primary' if you want stylish bootstrap button you can checkenter link description here

Community
  • 1
  • 1
slim_chebbi
  • 798
  • 6
  • 9