I can not submit the form post'om in Django. That just did not try, nothing helps.

urls.py

urlpatterns = patterns('', ..................... ..................... url(r'message/$', feedback, name='feedback'), ) 

The form:

  <h1>Обратная связь</h1> <form action="{% url feedback %}" method="post" id="feedback" name="feedback">{% csrf_token %} <input type="text" class="important" required placeholder="Пожайлуста представьтесь" name="name"> <input type="tel" class="important" name="phone" placeholder="Ваш телефон"> <input type="email"class="important" required name="email" placeholder="Ваш email"> <textarea name="message">Текст обращения</textarea> <input type="submit" name="send" value="Отправить" id="send"> </form> 

Representation:

 def feedback(request): return render_to_response(tpl,context_instance=RequestContext(request)) 

settings.py

 MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", ) 

Here is the error: CSRF verification failed. Request aborted.

  • I reread it 10 times and did everything as written - evgeniy
  • And why middleware and decorator? - neoascetic
  • Yes, because nothing helps ( - evgeniy
  • one
    Damn some restriction on the comments. If I’m not mistaken, the tag {% csrf_token%} should create a hidden field, but it doesn’t exist. - evgeniy

2 answers 2

In the above code, everything is correct. Even checked ompldr.org: jt.tar.bz2 . Share the rest.

  • Yeah fixed everything, thanks! - evgeniy

Django version 1.3.1. I didn’t remember exactly what I added to the context, but it didn’t work with him either.