Home > Blockchain >  How can I add attrs to image in the code given below
How can I add attrs to image in the code given below

Time:09-12

    widgets = {
        'img':forms.ImageInput(attrs={'class':'box'}), 
        'title':forms.TextInput(attrs={'class':'box'}), 
        'title':forms.TextInput(attrs={'class':'box'}),
        'title':forms.TextInput(attrs={'class':'box'}),
    }

'img':forms.ImageInput(attrs={'class':'box'}), this line gives me error.

CodePudding user response:

The widget for ImageField is FileInput not ImageInput, django has no widget called ImageInput...

Try this code

'img':forms.FileInput(attrs={'class': 'box'}),
  • Related