Почему форма не принимает значения?
Models:
class New_Volumes(models.Model):
new_id = models.IntegerField('ID')
name = models.CharField('Номер выпуска', max_length=150)
count_page = models.IntegerField('Кол-во страниц')
file = models.FileField('Выпуск', upload_to='static/main/comics')
def __str__(self):
return self.name
class Meta:
verbose_name = 'Выпуск'
verbose_name_plural = 'Выпуски'
forms:
class ChaptersForm(ModelForm):
class Meta:
model = New_Volumes
fields = ['new_id', 'name', 'count_page', 'file']
widgets = {
'new_id': NumberInput(attrs={
'сlass':"chapter-input",
'placeholder':"ID"
}),
'name': TextInput(attrs={
'placeholder': "Название выпуска",
'сlass': "chapter-input"
}),
'count_page': NumberInput(attrs={
'placeholder': "Кол-во страниц",
'сlass': "chapter-input"
}),
'file': FileInput(attrs={
'placeholder': "Название выпуска",
'сlass': "chapter-input"
})
}
views:
def add(request):
error = ''
if request.method == 'POST':
form = ChaptersForm(request.POST, request.FILES)
if form.is_valid():
form.save()
else:
error = 'Invalid Input'
form = ChaptersForm()
data = {
'form': form,
'error': error
}
return render(request, 'main/add.html', data)