enter image description here -views.py-
def store_create(request):
storeform = StoreForms(request.POST or None, request.FILES or None)
if request.method == 'POST':
form = storeform(request.POST)
if form.is_valid():
store = form.save()
return redirect(store.get_absolute_url())
else:
form = StoreForms()
return render(request, 'stores/store_create.html', {'form': form})
-urls.py-
path('new/', views.store_create, name='store_create'),
-create.html-
{% extends 'stores/base.html' %}
{% block title %}建立店家 | {{ block.super }}{% endblock title %}
{% block content %}
<form action="" method="post" role="form">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">建立</button>
<input type="hidden" name="csrfmiddlewaretoken" value="qfbg5BIB6818xpzy6Yz0OxOUcb8YxB2W">
</form>
{% endblock content %}
问题:
CSRF 验证失败。请求已中止。
请问为什么它仍然出现, CSRF 验证失败。请求已中止?
我的需求我都有,为什么我解决不了?