Thank you Kirby I found the error and now my code is running fine. Thanks
again

On Tue 8 May, 2018, 10:26 PM C. Kirby, <[email protected]> wrote:

> Seriously?
>
> path('<int:pk/', views.DetailView.as_view(), name='detail'),
> Should be
> path('<int:pk>/', views.DetailView.as_view(), name='detail'),
>
> You have posted several time in the last two days and every issue you have
> had has been a typo. People on this board are happy to help with django
> issues, but you should be really using an IDE that will catch at least some
> of these typos. PyCharm is a good one
>
> On Tuesday, May 8, 2018 at 12:52:15 PM UTC-4, Avitab Ayan Sarmah wrote:
>>
>> Please mention where exactly I missed >
>>
>>
>> On Tue 8 May, 2018, 10:19 PM C. Kirby, <[email protected]> wrote:
>>
>>> You are missing a closing '>' in your detail url
>>>
>>> On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:
>>>>
>>>> polls/urls.py:
>>>>
>>>> from django.urls import path
>>>>
>>>> from . import views
>>>>
>>>> app_name = 'polls'
>>>> urlpatterns = [
>>>> # ex: /polls/
>>>> path('', views.IndexView.as_view(), name='index'),
>>>> path('<int:pk/', views.DetailView.as_view(), name='detail'),
>>>> path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),
>>>> path('<int:question_id>/vote/', views.vote, name='vote'),
>>>> ]
>>>>
>>>>
>>>> On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>>>>>
>>>>> 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 <[email protected]
>>>>> > 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 [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/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  |  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
>>> [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/4047981b-ef18-4cce-9c8f-243bf86e6476%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/4047981b-ef18-4cce-9c8f-243bf86e6476%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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
> [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/8c5efad5-0e25-449d-8811-03ac78d6190a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8c5efad5-0e25-449d-8811-03ac78d6190a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 [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/CAEx5wm4bkjXEKz%3Ded7fqPTZf9di_eNegQw%3DXdZLqDtyA0pvYWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to