Re: Stuck with Django Tutorial Part 4

2023-03-15 Thread Chetan Ganji
It seems to me like you are not entering the url name
In place of 'polls:vote' try to enter the name of the url given to that url
For Your Reference
https://docs.djangoproject.com/en/4.1/ref/templates/builtins/#url
I hope it helps you!
Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 15, 2023 at 1:14 AM Sandip Bhattacharya <
sand...@showmethesource.org> wrote:

> Can you share your urls.py?
>
>
> On Mar 14, 2023, at 1:33 AM, Nithin Kumar  wrote:
>
> Hi,
>
> Stuck with this problem
>
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not
> found. 1 pattern(s) tried: ['polls/
> My detail.html is like this and it is failing at Line 1.
> I checked all solutions online but no luck.
>
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{%
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{
> choice.choice_text }}
> {% endfor %}
> 
> 
> 
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
> 
> .
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMKMUjthNav_nSy_%3Dci7mxQ-6OLRaXOzRJ6ZjGjAXap5nuY5Tg%40mail.gmail.com.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Nithin Kumar
Here.

urls.py

from django.urls import path

from . import views


app_name = 'polls'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('/', views.DetailView.as_view(), name='detail'),
path('/results/', views.ResultsView.as_view(), name='results'),
path('/vote/', views.vote, name='vote'),
]


On Tue, Mar 14, 2023 at 3:44 PM Sandip Bhattacharya <
sand...@showmethesource.org> wrote:

> Can you share your urls.py?
>
>
> On Mar 14, 2023, at 1:33 AM, Nithin Kumar  wrote:
>
> Hi,
>
> Stuck with this problem
>
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not
> found. 1 pattern(s) tried: ['polls/
> My detail.html is like this and it is failing at Line 1.
> I checked all solutions online but no luck.
>
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{%
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{
> choice.choice_text }}
> {% endfor %}
> 
> 
> 
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
> 
> .
>
>
> --
> 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/8mapBVGvyMA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALZgFFcJfRUyB7C-vHFug7BoqD_zhrp9xOccABKBFnLuFTLF_Q%40mail.gmail.com.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Prosper Lekia
This should be your views for vote.


from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse

from .models import Choice, Question
# ...
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()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(
question.id,)))

On Tue, Mar 14, 2023, 20:34 Nithin Kumar  wrote:

> question.id or question_id both gave the same result.
> These are the views.
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponse, Http404, HttpResponseRedirect
> from django.template import loader
> from .models import Choice,Question
> from django.urls import reverse
>
> # Create your views here.
>
> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html')
> context = {
> 'latest_question_list': latest_question_list,
> }
> return render(request, 'polls/index.html',context)
>
>
> def detail(request, question_id):
> try:
> question = Question.objects.get(pk=question_id)
> except Question.DoesNotExist:
> raise Http404("Question Does not exist")
> return render(request, 'polls/detail.html', {'question':question})
>
>
>
> def results(request, question_id):
> question = get_object_or_404(Question, pk=question_id)
> return render(request, 'polls/results.html', {'question': question})
>
> def vote(request, question_id):
> return HttpResponse("You're voting on question %s." % question_id)
>
>
>
>
>
> On Tuesday, March 14, 2023 at 1:22:25 PM UTC-4 Prosper Lekia wrote:
>
>> Let's see your views.
>>
>> On Tue, Mar 14, 2023, 14:32 Muhammad Juwaini Abdul Rahman <
>> juw...@gmail.com> wrote:
>>
>>> question_id=question.id
>>>
>>> On Tue, 14 Mar 2023 at 21:22, Nithin Kumar  wrote:
>>>
 Hi,

 Stuck with this problem

 https://docs.djangoproject.com/en/4.1/intro/tutorial04/

 NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)'
 not found. 1 pattern(s) tried: ['polls/>>>
 My detail.html is like this and it is failing at Line 1.
 I checked all solutions online but no luck.

 
 {% csrf_token %}
 
 {{ question.question_text }}
 {% if error_message %}{{ error_message }}
 {% endif %}
 {% for choice in question.choice_set.all %}
 
 {{
 choice.choice_text }}
 {% endfor %}
 
 
 

 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
 
 .

>>> --
>>> 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...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAFKhtoQ1tfqUempakxY7DHy26utEt3QN1iBbLBM78r5neYM3QQ%40mail.gmail.com
>>> 
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1d230ed2-73f0-4609-b53b-e620dff5d302n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe 

Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Brian Carey
I think you need to check your urls.py.

⁣Get BlueMail for Android ​

On Mar 14, 2023, 1:33 PM, at 1:33 PM, Nithin Kumar  
wrote:
>question.id or question_id both gave the same result.
>These are the views. 
>
>from django.shortcuts import get_object_or_404, render
>from django.http import HttpResponse, Http404, HttpResponseRedirect
>from django.template import loader
>from .models import Choice,Question
>from django.urls import reverse
>
># Create your views here.
>
>def index(request):
>latest_question_list = Question.objects.order_by('-pub_date')[:5]
>template = loader.get_template('polls/index.html') 
>context = {
>'latest_question_list': latest_question_list,
>}
>return render(request, 'polls/index.html',context)
>
>
>def detail(request, question_id):
>try:
>question = Question.objects.get(pk=question_id)
>except Question.DoesNotExist:
>raise Http404("Question Does not exist")
>return render(request, 'polls/detail.html', {'question':question})
>
>
>
>def results(request, question_id):
>question = get_object_or_404(Question, pk=question_id)
>   return render(request, 'polls/results.html', {'question': question})
>
>def vote(request, question_id):
>return HttpResponse("You're voting on question %s." % question_id)
>
>
>
>
>
>On Tuesday, March 14, 2023 at 1:22:25 PM UTC-4 Prosper Lekia wrote:
>
>> Let's see your views.
>>
>> On Tue, Mar 14, 2023, 14:32 Muhammad Juwaini Abdul Rahman <
>> juw...@gmail.com> wrote:
>>
>>> question_id=question.id
>>>
>>> On Tue, 14 Mar 2023 at 21:22, Nithin Kumar 
>wrote:
>>>
 Hi,

 Stuck with this problem 

 https://docs.djangoproject.com/en/4.1/intro/tutorial04/

 NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)'
>not 
 found. 1 pattern(s) tried: ['polls/>>>
 My detail.html is like this and it is failing at Line 1. 
 I checked all solutions online but no luck. 

 
 {% csrf_token %}
 
 {{ question.question_text }}
 {% if error_message %}{{ error_message }}
 {% endif %}
 {% for choice in question.choice_set.all %}
 
 {{ 
 choice.choice_text }}
 {% endfor %}
 
 
 

 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 

>https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
>

>
 .

>>> -- 
>>> 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...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>>
>https://groups.google.com/d/msgid/django-users/CAFKhtoQ1tfqUempakxY7DHy26utEt3QN1iBbLBM78r5neYM3QQ%40mail.gmail.com
>
>>>
>
>>> .
>>>
>>
>
>-- 
>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 view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/1d230ed2-73f0-4609-b53b-e620dff5d302n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21c8dec2-8e46-4885-8522-6eae37dd9ed9%40gmail.com.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Sandip Bhattacharya
Can you share your urls.py?


> On Mar 14, 2023, at 1:33 AM, Nithin Kumar  wrote:
> 
> Hi,
> 
> Stuck with this problem 
> 
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
> 
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not 
> found. 1 pattern(s) tried: ['polls/ 
> My detail.html is like this and it is failing at Line 1. 
> I checked all solutions online but no luck. 
> 
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{% 
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{ choice.choice_text 
> }}
> {% endfor %}
> 
> 
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
>  
> .

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Nithin Kumar
question.id or question_id both gave the same result.
These are the views. 

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.template import loader
from .models import Choice,Question
from django.urls import reverse

# Create your views here.

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html') 
context = {
'latest_question_list': latest_question_list,
}
return render(request, 'polls/index.html',context)


def detail(request, question_id):
try:
question = Question.objects.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question Does not exist")
return render(request, 'polls/detail.html', {'question':question})



def results(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/results.html', {'question': question})

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)





On Tuesday, March 14, 2023 at 1:22:25 PM UTC-4 Prosper Lekia wrote:

> Let's see your views.
>
> On Tue, Mar 14, 2023, 14:32 Muhammad Juwaini Abdul Rahman <
> juw...@gmail.com> wrote:
>
>> question_id=question.id
>>
>> On Tue, 14 Mar 2023 at 21:22, Nithin Kumar  wrote:
>>
>>> Hi,
>>>
>>> Stuck with this problem 
>>>
>>> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>>>
>>> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not 
>>> found. 1 pattern(s) tried: ['polls/>>
>>> My detail.html is like this and it is failing at Line 1. 
>>> I checked all solutions online but no luck. 
>>>
>>> 
>>> {% csrf_token %}
>>> 
>>> {{ question.question_text }}
>>> {% if error_message %}{{ error_message }}
>>> {% endif %}
>>> {% for choice in question.choice_set.all %}
>>> 
>>> {{ 
>>> choice.choice_text }}
>>> {% endfor %}
>>> 
>>> 
>>> 
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAFKhtoQ1tfqUempakxY7DHy26utEt3QN1iBbLBM78r5neYM3QQ%40mail.gmail.com
>>  
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1d230ed2-73f0-4609-b53b-e620dff5d302n%40googlegroups.com.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Prosper Lekia
Let's see your views.

On Tue, Mar 14, 2023, 14:32 Muhammad Juwaini Abdul Rahman 
wrote:

> question_id=question.id
>
> On Tue, 14 Mar 2023 at 21:22, Nithin Kumar 
> wrote:
>
>> Hi,
>>
>> Stuck with this problem
>>
>> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>>
>> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not
>> found. 1 pattern(s) tried: ['polls/>
>> My detail.html is like this and it is failing at Line 1.
>> I checked all solutions online but no luck.
>>
>> 
>> {% csrf_token %}
>> 
>> {{ question.question_text }}
>> {% if error_message %}{{ error_message }}{%
>> endif %}
>> {% for choice in question.choice_set.all %}
>> 
>> {{
>> choice.choice_text }}
>> {% endfor %}
>> 
>> 
>> 
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFKhtoQ1tfqUempakxY7DHy26utEt3QN1iBbLBM78r5neYM3QQ%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALGeGE3X4o_uE-302%2Bt36q%2B%3DVToch7qfYWDdxuY94bXsUk4FGg%40mail.gmail.com.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Muhammad Juwaini Abdul Rahman
question_id=question.id

On Tue, 14 Mar 2023 at 21:22, Nithin Kumar  wrote:

> Hi,
>
> Stuck with this problem
>
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not
> found. 1 pattern(s) tried: ['polls/
> My detail.html is like this and it is failing at Line 1.
> I checked all solutions online but no luck.
>
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{%
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{
> choice.choice_text }}
> {% endfor %}
> 
> 
> 
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFKhtoQ1tfqUempakxY7DHy26utEt3QN1iBbLBM78r5neYM3QQ%40mail.gmail.com.


Stuck with Django Tutorial Part 4

2023-03-14 Thread Nithin Kumar
Hi,

Stuck with this problem 

https://docs.djangoproject.com/en/4.1/intro/tutorial04/

NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not 
found. 1 pattern(s) tried: ['polls/
{% csrf_token %}

{{ question.question_text }}
{% if error_message %}{{ error_message }}{% 
endif %}
{% for choice in question.choice_set.all %}

{{ choice.choice_text 
}}
{% endfor %}




-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com.