Forbidden (CSRF token missing or incorrect.) Django + AngularJs
<p>When I try to render to my second page in my django framework I get following error. I think that there is something wrong with my url page and views.py but can't figure it out, nothing gives a step forward..</p>

<pre><code>Forbidden (CSRF token missing or incorrect.): /renderbonds
[06/Sep/2016 00:21:55] "POST /renderbonds HTTP/1.1" 403 2502
</code></pre>

<p>this is my html/django form</p>

<pre><code>&lt;form action="{% url 'renderbonds'%}" method="post" &gt;
                &lt;input type="submit" value="calculate bonds" class='button expand radius'/&gt;
            &lt;/form&gt;
</code></pre>

<p>Views.py python file:</p>

<pre><code>def home(request):
    tmpl_vars = {
        'all_posts': Post.objects.reverse(),
        'form': PostForm()
    }
    return render(request, 'pricing/bonds.html', tmpl_vars)

def renderbonds(request):
    """render shortcut : http://stackoverflow.com/questions/10388033/csrf-verification-failed-request-aborted"""
    if request.method == 'POST':
        post_text = request.POST.get('the_post')
        response_data = {}

        post = Post(text=post_text, author=request.user)
        post.save()

        """DATA MEEGEVEN"""
        response_data['year'] = post.year
        response_data['cashflow'] = post.cashflow

        return HttpResponse(
            json.dumps(response_data),
            content_type="application/json"
        )
    else:
        tmpl_vars = {
            'all_posts': Post.objects.reverse(),
            'form': PostForm()
        }
        return render(request,'pricing/bonds.html', tmpl_vars)
</code></pre>

<p>my urls:</p>

<pre><code>urlpatterns = [
    url(r'^$', views.calc,name='calc'),
    url(r'^$', views.home,'home'),
    url(r'^create_post/$',views.create_post,'create_post'),
    url(r'^renderbonds', views.home, name='home'),
    url(r'^/renderbonds', views.home, name='home'),
    url(r'^renderbonds/', views.home, name='home')

]
</code></pre>

<p>The issue is not with your urls or your views, but with your template. Try adding <code>{% csrf_token %}</code> nested under your <code>&lt;form&gt;&lt;/form&gt;</code> tags in your template. </p>

<pre><code>&lt;form action="{% url 'renderbonds'%}" method="post" &gt;
    &lt;input type="submit" value="calculate bonds" class='button expand radius'/&gt;
    {% csrf_token %}
&lt;/form&gt;
</code></pre>

<p>See <a href="https://docs.djangoproject.com/en/1.10/ref/csrf/" rel="nofollow">the docs</a> for more details. </p>

python angularjs django