28 lines
804 B
Python
28 lines
804 B
Python
from django import forms
|
|
|
|
from apps.gto.models.model_type_icons import ModelTypeIcons
|
|
from apps.management.forms.icon import validate_image
|
|
|
|
|
|
class ModelTypeIconsForm(forms.ModelForm):
|
|
icon = forms.ImageField(
|
|
required=True,
|
|
validators=[validate_image],
|
|
widget=forms.FileInput(
|
|
attrs={"class": "custom-file-input", "accept": "image/*",
|
|
"lang": "ru"}
|
|
),
|
|
)
|
|
|
|
class Meta:
|
|
model = ModelTypeIcons
|
|
fields = ["model", "icon"]
|
|
widgets = {
|
|
"model": forms.TextInput(attrs={
|
|
"autocomplete": "off",
|
|
"autofocus": True,
|
|
"class": "form-control",
|
|
"placeholder": "Введите наименование"
|
|
}
|
|
),
|
|
} |