how to get POST data in django 1.3

后端 未结 4 901
感情败类
感情败类 2021-02-06 02:49

Hey, I am following this tutorial to learn to make a wiki page with Django. However, it is made in django 0.96 and I use Django 1.3 so there are some things that are different.

4条回答
  •  执笔经年
    2021-02-06 03:38

    You've got to include {% csrf_token %} in your form's template between your

    tags.

    
        {% csrf_token %}
        

    If the csrf_token is not rendered into your form make sure you're providing the RequestContext in the view's response:

    from django.shortcuts import render_to_response
    from django.template import RequestContext
    
    def app_view(request):
        return render_to_response('app_template.html', 
                                  app_data_dictionary, 
                                  context_instance=RequestContext(request))
    

    Or, use this shortcut method:

    from django.views.generic.simple import direct_to_template
    
    def app_view(request):             
        return direct_to_template(request, 'app_template.html', app_data_dictionary)
    

    The RequestContext is always available when you're using generic views.

提交回复
热议问题