Почему он не сохраняет запись в бд и не перекидывает меня на страницу news/ ?
views
from django.shortcuts import render, redirect
from .models import Articles
from .forms import ArticlesForm
def news_home(request):
news = Articles.objects.order_by('-data')
return render(request, 'news/news_home.html', {'news': news})
def create(request):
error = ''
if request.method == "POST":
form = ArticlesForm(request.POST)
if form.is_valid():
form.save()
return redirect('news/')
else:
print(form.errors)
error = 'Неверная форма'
form = ArticlesForm()
data = {
'form': form,
'error': error
}
return render(request, 'news/create.html', data)
HTML
{% extends 'main/Allin.html' %}
{% load static %}
{% block title %} Form To Add {% endblock %}
{% block content %}
<div class="features">
<h1>Form To Add</h1>
<form method="post">
{% csrf_token %}
{{ form.title }}<br>
{{ form.anons }}<br>
{{ form.dates }}<br>
{{ form.full_text }}<br>
<button class="btn btn-success" type="submit">Add</button>
</form>
</div>
{% endblock %}