how to get POST data in django 1.3

后端 未结 4 902
感情败类
感情败类 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:34

    I guess you've missed the symbol '=' in the form declaration.

    action"/wikicamp/{{page_name}}/save/"
    
    action="/wikicamp/{{page_name}}/save/"
    

    Fortunately, it might be not a mistake. So if it is not a solution, try some more easy example:

    # settings.py
    
    TEMPLATE_DIRS = (
        # Here comes something like "C:/www/django/templates"
    )
    
    MIDDLEWARE_CLASSES = (
        ...
        'django.middleware.csrf.CsrfViewMiddleware',
        ...
    )
    
    # urls.py
    
    urlpatterns = patterns('',
        ('^foo', foo),
    )
    
    
    # views.py
    from django.http import HttpResponse
    from django.shortcuts import render_to_response
    from django.core.context_processors import csrf
    
    def foo(request):
        d = {}
        d.update(csrf(request))
        if 'output' in request.POST:
            d.update({'output':request.POST['output']})
        return render_to_response('foo.html',d)
    
    # foo.html template
    
    

    Foo

    {% csrf_token %}

    Output: {{ output }}

    Hope this will work

提交回复
热议问题