When you type in the url it submits a GET, but the form submission (an the 
error tell this explicitly) uses a POST. Likely you did not handle a POST 
method in your view.

On Wednesday, April 5, 2017 at 6:25:23 PM UTC+3, Chris Chan wrote:
>
> Hi,
> I'm try to follow the Django tutorial and modify something but failure.
> When I execute the web page is error and the Django server console said " 
> Method not allowed (Post): /polls/3/results/"
> But I'm type address : http://127.0.0.1:8000/polls/3/results/ is fine, 
> thanks
>
> In "First app, Part 4",
> I created Index List view and the Detail & Results , DetailView
>
> In "detail.html" I try to modify below coding
>
> <!DOCTYPE html>
> <html lang="en">
> <head>
>     <meta charset="UTF-8">
>     <title>Detail</title>
> </head>
> <body>
> <h1>{{ question.question_text }}</h1>
>     {% if error_message %}<p><strong>{{error_message}}</strong></p>{% endif %}
>
> <form action="{% url 'polls:results' question.id %}" method="post">
> {% csrf_token %}
> {% for choice in question.choice_set.all %}
>     <input type="radio" name="choice" id="choice{{ forloop.counter }}" 
> value="{{ choice.id }}" />
>     <label for="choice{{ forloop.counter }}">{{ choice.choice_text 
> }}</label><br />
> {% endfor %}
> <input type="submit" value="Vote" />
>
> </form>
> </body>
> </html>
>
>
> In the "url.py"
>
> from django.conf.urls import url
>
> from . import views
>
> app_name = 'polls'
> urlpatterns = [
>     url(r'^$', views.IndexView.as_view(), name='index'),
> #    url(r'^$', views.index, name='index'),
> #    url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
>     url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),
>     url(r'^(?P<pk>[0-9]+)/results/$', views.ResultsView.as_view(), 
> name='results'),
> #    url(r'^(?P<question_id>[0-9]+)/results/$', views.results, 
> name='results'),
>     url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db681baa-0f28-48ee-b0f3-2460c23f4b5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to