how passing Question and pk=question_id gonna help?

On Sunday, April 14, 2019 at 5:41:06 PM UTC+5:30, gulam rabbani wrote:
>
> It will give you to fetch the id ! Until end of the id 
>
> On Sun, 14 Apr, 2019 at 1:47 PM, Mayur Bagul <[email protected] 
> <javascript:>> wrote:
>
>> In below code i didnt understand how colored line of code is working with 
>> template code ?
>>
>> why we are passing Question and primary key? instead of dictionary to 
>> context variable.
>>
>> plz help me to get out of this confusion.
>>
>> thanking you.
>>
>>
>>  *view.py*
>>
>>
>> from django.shortcuts import get_object_or_404, render
>>
>> from .models import Question
>> # ...
>> def detail(request, question_id):
>>     question = get_object_or_404(Question, pk=question_id)
>>     return render(request, 'polls/detail.html', {'question': question})
>>
>>
>>
>>  *detail.html*
>>
>>
>> <h1>{{ question.question_text }}</h1>
>> <ul>
>> {% for choice in question.choice_set.all %}
>>     <li>{{ choice.choice_text }}</li>
>> {% endfor %}
>> </ul>
>>
>>
>>
>>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%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/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to