Your problem is your urls.py:

django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments
'(1,)' not found. 1 pattern(s) tried: ['\\<int\\:pk\\/$']

You are looking for a URL named "details" which accepts 1 number and Django
does not know it.

On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah <avitabay...@gmail.com>
wrote:

> Exceptions:
>
> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
> Performing system checks...
>
> System check identified no issues (0 silenced).
> May 08, 2018 - 22:00:28
> Django 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 inner
>     response = get_response(request)
>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", line
> 158, in _get_response
>     response = self.process_exception_by_middleware(e, request)
>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", line
> 156, in _get_response
>     response = response.render()
>   File "c:\python36\lib\site-packages\django\template\response.py", line
> 106, in render
>     self.content = self.rendered_content
>   File "c:\python36\lib\site-packages\django\template\response.py", line
> 83, in rendered_content
>     content = template.render(context, self._request)
>   File "c:\python36\lib\site-packages\django\template\backends\django.py",
> line 61, in render
>     return self.template.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 175,
> in render
>     return self._render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 167,
> in _render
>     return self.nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
> in render
>     bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
>     return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 314, in render
>     return nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
> in render
>     bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
>     return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 211, in render
>     nodelist.append(node.render_annotated(context))
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
>     return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 447, in render
>     url = reverse(view_name, args=args, kwargs=kwargs,
> current_app=current_app)
>   File "c:\python36\lib\site-packages\django\urls\base.py", line 88, in
> reverse
>     return 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_prefix
>     raise 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 134672
>
> views.py:
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect
> from django.urls import reverse
> from django.views import generic
>
> from . models import Choice, Question
>
>
> class 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 = Question
> template_name = 'polls/detail.html'
>
>
> class ResultsView(generic.DetailView):
> model = Question
> template_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 +=1
> selected_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+unsubscr...@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
> <https://groups.google.com/d/msgid/django-users/1681bb6e-226e-4792-ab5c-1cadcf836eff%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101 <callto:+555130838101>  |  Mobile: +55 51
<callto:+5551996209291>*99907 0554*

-- 
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+unsubscr...@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.

Reply via email to