Note that there are some explanatory texts on larger screens.

plurals
  1. POform action not working in django
    primarykey
    data
    text
    <p>I have django 1.4 and I am following a tutorial which uses an older version of django. Its a simple tutorial which creates a wiki app with Page as model. </p> <p>The problem is that the view function corresponding to a POST method in a form is not getting invoked.</p> <p>This is the content in the urls.py:</p> <pre><code>url(r'^wikicamp/(?P&lt;page_name&gt;[^/]+)/edit/$', 'wiki.views.edit_page'), url(r'^wikicamp/(?P&lt;page_name&gt;[^/]+)/save/$', 'wiki.views.save_page'), url(r'^wikicamp/(?P&lt;page_name&gt;[^/]+)/$', 'wiki.views.view_page'), </code></pre> <p>This is the content of the template edit.html:</p> <pre><code>&lt;from method = "get" action="/wikicamp/{{page_name}}/save/"&gt; {% csrf_token %} &lt;textarea name = "content" rows="20" cols="60"&gt; {{content}} &lt;/textarea&gt; &lt;br/&gt; &lt;input type="submit" value="Save Page"/&gt; &lt;/form&gt; &lt;a href="/wikicamp/{{page_name}}/save/"&gt;this is link to save&lt;/a&gt; </code></pre> <p>And this is the content in views.py:</p> <pre><code>def edit_page(request, page_name): try: page = Page.objects.get(pk=page_name) content = page.content except Page.DoesNotExist: content = "" return render_to_response("edit.html", {"page_name":page_name, "content":content}, context_instance=RequestContext(request)) def save_page(request, page_name): return HttpResponse("You're looking at the page %s." % page_name) </code></pre> <p>I initially I was getting csrf related error and I then tried all the fixes provided in <a href="https://docs.djangoproject.com/en/dev/ref/contrib/casrf/" rel="nofollow">https://docs.djangoproject.com/en/dev/ref/contrib/casrf/</a> and followed many many stackoverflow question related to POST and django. Now nothing happens when I click the 'Save Page' button, nothing! Not even any request being sent from the form (Using firebug to track the HTTP request and response)</p>
    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.
    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