Wait I am sharing my URLs.py
On Tue 8 May, 2018, 10:09 PM Julio Biason, <julio.biason@azion.com> wrote:
Your problem is your urls.py:You are looking for a URL named "details" which accepts 1 number and Django does not know it.django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments '(1,)' not found. 1 pattern(s) tried: ['\\<int\\:pk\\/$']--On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah <avitabayans@gmail.com> wrote:Exceptions:--PS C:\Users\AVITABAYAN\mysite> python manage.py runserverPerforming system checks...System check identified no issues (0 silenced).May 08, 2018 - 22:00:28Django version 2.0.1, using settings 'mysite.settings'Starting development server at http://127.0.0.1:8000/Quit the server with CTRL-BREAK.Internal Server Error: /Traceback (most recent call last):File "c:\python36\lib\site-packages\django\core\handlers\exception.py", line 35, in innerresponse = get_response(request)File "c:\python36\lib\site-packages\django\core\handlers\base.py", line 158, in _get_responseresponse = self.process_exception_by_middleware(e, request)File "c:\python36\lib\site-packages\django\core\handlers\base.py", line 156, in _get_responseresponse = response.render()File "c:\python36\lib\site-packages\django\template\response.py", line 106, in renderself.content = self.rendered_contentFile "c:\python36\lib\site-packages\django\template\response.py", line 83, in rendered_contentcontent = template.render(context, self._request)File "c:\python36\lib\site-packages\django\template\backends\django.py", line 61, in renderreturn self.template.render(context)File "c:\python36\lib\site-packages\django\template\base.py", line 175, in renderreturn self._render(context)File "c:\python36\lib\site-packages\django\template\base.py", line 167, in _renderreturn self.nodelist.render(context)File "c:\python36\lib\site-packages\django\template\base.py", line 943, in renderbit = node.render_annotated(context)File "c:\python36\lib\site-packages\django\template\base.py", line 910, in render_annotatedreturn self.render(context)File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 314, in renderreturn nodelist.render(context)File "c:\python36\lib\site-packages\django\template\base.py", line 943, in renderbit = node.render_annotated(context)File "c:\python36\lib\site-packages\django\template\base.py", line 910, in render_annotatedreturn self.render(context)File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 211, in rendernodelist.append(node.render_annotated(context))File "c:\python36\lib\site-packages\django\template\base.py", line 910, in render_annotatedreturn self.render(context)File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 447, in renderurl = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)File "c:\python36\lib\site-packages\django\urls\base.py", line 88, in reversereturn iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 632, in _reverse_with_prefixraise NoReverseMatch(msg)django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments '(1,)' not found. 1 pattern(s) tried: ['\\<int\\:pk\\/$'][08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672views.py:from django.shortcuts import get_object_or_404, renderfrom django.http import HttpResponseRedirectfrom django.urls import reversefrom django.views import genericfrom . models import Choice, Questionclass IndexView(generic.ListView):template_name = 'polls/index.html'context_object_name = 'latest_question_list'def get_queryset(self):"""Return the last five published questions."""return Question.objects.order_by('-pub_date')[:5]class DetailView(generic.DetailView):model = Questiontemplate_name = 'polls/detail.html'class ResultsView(generic.DetailView):model = Questiontemplate_name = 'polls/results.html'def vote(request, question_id):question = get_object_or_404(Question, pk=question_id)try:selected_choice = question.choice_set.get(pk=request.POST['choice'])except (KeyError, Choice.DoesNotExist):#Redisplay the question voting form.return render(request, 'polls/detail.html', {'question': question,'error_message': "you didn't select a choice.",})else:selected_choice.votes +=1selected_choice.save()#...#...#...return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))index.html:{% if latest_question_list %}<ul>{% for question in latest_question_list %}<li><a href="{% url 'polls:detail' question.id %}">{{question.question_text }}</a></li>{% endfor %}</ul>{% else %}<p>No polls are available.</p>{% endif %}
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/1681bb6e-226e-4792-ab5c-1cadcf836eff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Julio Biason, Sofware EngineerAZION | Deliver. Accelerate. Protect.Office: +55 51 3083 8101 | Mobile: +55 51 99907 0554
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/BgTiafZjozA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAEM7gE0R1HHUz-2S-U_RHts240J80U7V8iqQcCJTULSvhKZy_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAEx5wm7J2XK7W820Sk6hvFhO9YCbub2wB3TcQ6gukTXyjNHq7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment