Есть форма для отправки отзывов, когда пытаюсь её отправить, перебрасывает на пустую страницу, и в консоли появляется ошибка Method Not Allowed (POST).
views
class Feedback(CreateView):
form_class = FeedbackForm
model = Feedback
success_url = reverse_lazy('home')
urls
from django.urls import path
from .views import *
urlpatterns = [
path('', home, name='home'),
path('<str:slug>/', HomePage.as_view(), name='type'),
path('feedback/', Feedback.as_view(), name='feedback')
]
form
from django import forms
from .models import *
class FeedbackForm(forms.ModelForm):
class Meta:
model = Feedback
fields = ['name', 'email', 'comment']
widgets = {
'name': forms.TextInput(attrs={'class': 'form-control col-8', 'placeholder': 'Name'}),
'email': forms.EmailInput(attrs={'class': 'form-control col-8', 'placeholder': 'Email'}),
'comment': forms.TextInput(attrs={'class': 'form-control col-8', 'placeholder': 'Comment'})
}
labels = {
'name': '',
'email': '',
'comment': ''
}
html
<div class="save-sum container container-cat bg-dark mb-4">
<h4 class="text-light p-2">Write comment about our app</h4>
<div class="input-group mb-3">
<form action="{% url 'feedback' %}" method="post">
{% csrf_token %}
{{ feedback_form.as_p }}
<div class="input-group-append">
<button class="btn btn-success" type="submit">Send</button>
</div>
</form>
</div>
</div>
models
class Feedback(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
comment = models.TextField()
created = models.DateTimeField(auto_now_add=True)