Django: CSRF verification failed. Request aborted
<p>The called view function is like this </p>

<pre><code>def parsing(request):
    url = request.POST['url']
    ...
    return HttpResponse(json.dumps(resultDict))
</code></pre>

<p>When I make a post request to it via the following code,</p>

<pre><code>import requests
url = 'http://tv.cntv.cn/video/C12278/a7ea7c0e810b4701bf1d3f5254b8a26a'
c = requests.post("http://127.0.0.1:8000/VideoParser/", data={'url': url})
print(c.text)
</code></pre>

<p>then the request failed and it just give out the following HTML code, </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
  &lt;meta name="robots" content="NONE,NOARCHIVE"&gt;
  &lt;title&gt;403 Forbidden&lt;/title&gt;
  &lt;style type="text/css"&gt;
    html * { padding:0; margin:0; }
    body * { padding:10px 20px; }
    body * * { padding:0; }
    body { font:small sans-serif; background:#eee; }
    body&gt;div { border-bottom:1px solid #ddd; }
    h1 { font-weight:normal; margin-bottom:.4em; }
    h1 span { font-size:60%; color:#666; font-weight:normal; }
    #info { background:#f6f6f6; }
    #info ul { margin: 0.5em 4em; }
    #info p, #summary p { padding-top:10px; }
    #summary { background: #ffc; }
    #explanation { background:#eee; border-bottom: 0px none; }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="summary"&gt;
  &lt;h1&gt;Forbidden &lt;span&gt;(403)&lt;/span&gt;&lt;/h1&gt;
  &lt;p&gt;CSRF verification failed. Request aborted.&lt;/p&gt;


  &lt;p&gt;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.&lt;/p&gt;
  &lt;p&gt;If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for &amp;#39;same-origin&amp;#39; requests.&lt;/p&gt;

&lt;/div&gt;

&lt;div id="info"&gt;
  &lt;h2&gt;Help&lt;/h2&gt;
    
    &lt;p&gt;Reason given for failure:&lt;/p&gt;
    &lt;pre&gt;
    CSRF cookie not set.
    &lt;/pre&gt;
    

  &lt;p&gt;In general, this can occur when there is a genuine Cross Site Request Forgery, or when
  &lt;a
  href="https://docs.djangoproject.com/en/1.9/ref/csrf/"&gt;Django's
  CSRF mechanism&lt;/a&gt; has not been used correctly.  For POST forms, you need to
  ensure:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;Your browser is accepting cookies.&lt;/li&gt;

    &lt;li&gt;The view function passes a &lt;code&gt;request&lt;/code&gt; to the template's &lt;a
    href="https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render"&gt;&lt;code&gt;render&lt;/code&gt;&lt;/a&gt;
    method.&lt;/li&gt;

    &lt;li&gt;In the template, there is a &lt;code&gt;{% csrf_token
    %}&lt;/code&gt; template tag inside each POST form that
    targets an internal URL.&lt;/li&gt;

    &lt;li&gt;If you are not using &lt;code&gt;CsrfViewMiddleware&lt;/code&gt;, then you must use
    &lt;code&gt;csrf_protect&lt;/code&gt; on any views that use the &lt;code&gt;csrf_token&lt;/code&gt;
    template tag, as well as those that accept the POST data.&lt;/li&gt;

  &lt;/ul&gt;

  &lt;p&gt;You're seeing the help section of this page because you have &lt;code&gt;DEBUG =
  True&lt;/code&gt; in your Django settings file. Change that to &lt;code&gt;False&lt;/code&gt;,
  and only the initial error message will be displayed.  &lt;/p&gt;

  &lt;p&gt;You can customize this page using the CSRF_FAILURE_VIEW setting.&lt;/p&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>It seems reason given for failure is</p>

<p>CSRF cookie not set.</p>

<p>however, my app doesn't involve any cookie and template explicitly during the whole process, anyone can help fix the problem ? I am just a beginning Django learner .</p>