Я пытаюсь сохранить POST в моей форме.
views.py
def index(request):
if request.method == 'POST':
print('!PRINT request.POST')
print(request.POST)
form = PostForm(request.POST, request.FILES)
print('!PRINT form')
print(form)
if form.is_valid():
form.save()
return redirect('/')
возвращено:! PRINT request.POST
~ 'title': ['Bart', 'Mat'], 'Create Match': ['Submit']}>
! PRINT form
~ name = "title" value = "Mat" maxlength = "200" требуется id = "id_title"
~ name = "title1" class = "errorlist" Это поле обязательно для заполнения.
forms.py
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = '__all__'
models.py
class Post(models.Model):
title = models.CharField(max_length=200)
title1 = models.CharField(max_length=200)
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
список. html
<form method="POST" enctype="multipart/form-data" action="/">
{% csrf_token %}
{{ form.title }}
{{ form.title }}
<input type="submit" name="Create Match">
</form>>