def clean_cover(self):
cover = self.cleaned_data['cover']
- if cover and cover.name.rsplit('.', 1)[-1].lower() not in ('jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'):
+ if cover and cover.name.rsplit('.', 1)[-1].lower() not in ('jpg', 'jpeg', 'png', 'gif', 'svg'):
raise forms.ValidationError(_('The cover should be an image file (jpg/png/gif)'))
return file
self.category = category
self.instance = instance
self.field().queryset = Tag.objects.filter(category=self.category)
- self.field().label = self.category.label
+ self.field().label = self.category.label.capitalize()
if self.instance:
self.field().initial = self.initial()
class TagSingleForm(TagForm):
- tag = forms.ModelChoiceField(Tag.objects.none())
+ tag = forms.ModelChoiceField(
+ Tag.objects.none(),
+ widget=forms.Select(attrs={
+ 'class': 'form-control',
+ })
+ )
def field(self):
return self.fields['tag']
class TagMultipleForm(TagForm):
- tags = forms.ModelMultipleChoiceField(Tag.objects.none(), required=False)
+ tags = forms.ModelMultipleChoiceField(
+ Tag.objects.none(), required=False,
+ widget=forms.SelectMultiple(attrs={
+ 'class': 'chosen-select',
+ 'data-placeholder': _('Choose'),
+ }))
def field(self):
return self.fields['tags']