Note that there are some explanatory texts on larger screens.

plurals
  1. POCSRF Django, ValueError
    primarykey
    data
    text
    <p>I follow the tutorial <a href="https://docs.djangoproject.com/en/dev/ref/contrib/csrf/" rel="nofollow">here</a> but i get the following error</p> <p>ValueError at /mapapp/ dictionary update sequence element #0 has length 1; 2 is required</p> <p>These are all the files which has csrf related code in them</p> <p><strong>views.py</strong></p> <pre><code>from django.core.context_processors import csrf from django.shortcuts import render_to_response from django.template import Template, Context from django.http import HttpResponse from mapvis.store import * import datetime def mapapp(request): csrfprotection = {} csrfprotection.update(csrf(request)) .... return render_to_response('mapvis/mapapp.html', c, csrfprotection) </code></pre> <p><strong>settings.py</strong></p> <pre><code>MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) </code></pre> <p><strong>mappapp.html</strong></p> <pre><code>&lt;body&gt; &lt;div id="map_canvas"&gt;&lt;/div&gt; &lt;form method="post"&gt;{% csrf_token %} &lt;strong&gt;Start&lt;/strong&gt;&lt;br&gt; Lng: &lt;input type="text" id="start_lng"&gt;&lt;br&gt; Lat: &lt;input type="text" id="start_lat"&gt;&lt;br&gt; &lt;strong&gt;Destination&lt;/strong&gt;&lt;br&gt; Lng: &lt;input type="text" id="dest_lng"&gt;&lt;br&gt; Lat: &lt;input type="text" id="dest_lat"&gt;&lt;br&gt; &lt;input type="submit" style="background-color:#64FE2E" type="button" id="go" value="go"&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>:EDIT</p> <pre><code>Internal Server Error: /mapapp/ Traceback (most recent call last): File "/sw/django-1.5.4/lib/python3.2/site-packages/django/core/handlers/base.py", line 115, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/piehe154/maps/lmap/mapvis/views.py", line 28, in mapapp return render_to_response('mapvis/mapapp.html', c, csrfprotection) File "/sw/django-1.5.4/lib/python3.2/site-packages/django/shortcuts/__init__.py", line 29, in render_to_response return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "/sw/django-1.5.4/lib/python3.2/site-packages/django/template/loader.py", line 175, in render_to_string context_instance.update(dictionary) ValueError: dictionary update sequence element #0 has length 1; 2 is required </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload