Привет, я - пользователь python и django. < /p>
Я буду следовать этому вопросу (могу ли я иметь форму django без модели)
, но для моей задачи мне нужны изображения.
Я попытаюсь запустить свой код, и у меня есть эта ошибка, которая зарекомендовала себя (403): любая идея, как исправить это?Forbidden (403)
CSRF verification failed. Request aborted.
You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties.
If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for 'same-origin' requests.
< /code>
views.py
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.template import RequestContext
from blog.forms import MyForm
# Create your views here.
def form_handle(request):
form = MyForm()
if request.method=='POST':
form = MyForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
#now in the object cd, you have the form as a dictionary.
a = cd.get('a')
return render_to_response('blog/calc.html', {'form': form}, RequestContext(request))
< /code>
urls.py
from django.conf.urls import url
from . import views
< /code>
forms.py
from django import forms
class MyForm(forms.Form): #Note that it is not inheriting from forms.ModelForm
a = forms.ImageField()
#All my attributes here
< /code>
urls.py
urlpatterns = [
url(r'^$',views.form_handle, name='form_handle'),
]
< /code>
html < /p>
Title
{% csrf_token %}
{{form.as_p}}
Submit
Подробнее здесь: https://stackoverflow.com/questions/421 ... ing-django
Запретная (403) Проверка CSRF не удалась. Запрос прерван с помощью django ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Запретная (403) Проверка CSRF не удалась. Запрос прерван. во время входа в Label Studio
Anonymous » » в форуме Python - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Запрещено (403). CSRF-проверка не удалась. Запрос прерван с помощью Django
Anonymous » » в форуме Python - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Запрещено (403). Проверка CSRF не удалась. Запрос прерван с помощью Django
Anonymous » » в форуме Python - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-