I am trying to process a post form, but I can't manage. I have prepared the form, gave the action link, set the method to post, but when I hit the submit button, nothing happens, not even an error page isn't shown by django despite my debug option is True.
Here is the form code in my template file:
<form method="post" action="{% url 'articles:stepprocess' 0 %}"> {% csrf_token %} <p><label for="title">Title:</label> <input name="title" id="title" type="text"/></p> <p> <label for="dif">Difficulty</label> <select name="dif" id="dif"> {% if difficulties %} {% for difficulty in difficulties %} <option value="{{ difficulty.pk }}">{{ difficulty }}</option> {% endfor %} {% endif %} </select> </p> <p><label for="article">Content:</label> <textarea cols="37" rows="11" name="article" id="article"></textarea></p> <p><input name="send" style="margin-left: 150px;" class="formbutton" value="Send" type="submit"/></p> </form> My urls.py file:
from django.conf.urls import url from .views import * urlpatterns = [ url(r'^$', Index.as_view(), name="index"), url(r'^new/(?P<step>[0-9]+)/$', NewArticle.as_view(), name="newarticle_continue"), url(r'^new/', NewArticle.as_view(), name="newarticle"), url(r'^new/process/(?P<step>[0-9]+)/$', FormManager.as_view(), name='stepprocess') #url(r'^show/(?P<article>[0-9]+)/$'), ] And lastly, my views.py file:
#required imports... class FormManager(View): def post(self, request, *args, **kwargs): return HttpResponse(kwargs['step']) When I hit the submit button, it gives me HTTP 405 error. I can see this error in python console but nothing shows in browser. Just blank white screen.
This was actually to test if view works properly. My final purpose is that I would like to access the post variables and redirect the page. However, HttpResponseRedirect also doesn't work. How can I fix this?