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'}))

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.