Re: How this Line of code works

2019-04-16 Thread Milind Thombre
hi Mayur,
What does this application do?
Milind

On Tue, Apr 16, 2019 at 10:16 AM Mayur Bagul  wrote:

> hello jani,
>
> thanks for hep. i read django doc and this is the example from it but
> there is no information provided for why these parameters are used.
> but thanks for your information it is useful like others gave me.
>
> thanking you.
>
> On Monday, April 15, 2019 at 11:59:51 AM UTC+5:30, Jani Tiainen wrote:
>>
>> Hi.
>>
>> get_object_or_404 works so that first argument is the model class you
>> want to query. Rest of the parameters are filters that mus return a single
>> object.
>>
>> You can find this information from the Django docs as well.
>>
>>
>> ma 15. huhtik. 2019 klo 7.23 Mayur Bagul  kirjoitti:
>>
>>> 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 
 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*
>
>
> {{ question.question_text }}
> 
> {% 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...@googlegroups.com.
> To post to this group, send email to django...@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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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...@googlegroups.com.
>>> To post to this group, send email to django...@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/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.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+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/dd2ef12b-0732-4181-b80f-87ea40c438db%40googlegroups.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+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/CABfVtFFWk6D%3DNfb5Co4b2U6xqGy6Jkizh8X3rLve8xSCXFSPEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-15 Thread Mayur Bagul
hello jani,

thanks for hep. i read django doc and this is the example from it but there 
is no information provided for why these parameters are used. 
but thanks for your information it is useful like others gave me.

thanking you.

On Monday, April 15, 2019 at 11:59:51 AM UTC+5:30, Jani Tiainen wrote:
>
> Hi.
>
> get_object_or_404 works so that first argument is the model class you want 
> to query. Rest of the parameters are filters that mus return a single 
> object.
>
> You can find this information from the Django docs as well.
>
>
> ma 15. huhtik. 2019 klo 7.23 Mayur Bagul > 
> kirjoitti:
>
>> 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  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*


 {{ question.question_text }}
 
 {% 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...@googlegroups.com.
 To post to this group, send email to django...@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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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...@googlegroups.com .
>> To post to this group, send email to django...@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/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.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+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/dd2ef12b-0732-4181-b80f-87ea40c438db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-14 Thread Jani Tiainen
Hi.

get_object_or_404 works so that first argument is the model class you want
to query. Rest of the parameters are filters that mus return a single
object.

You can find this information from the Django docs as well.


ma 15. huhtik. 2019 klo 7.23 Mayur Bagul  kirjoitti:

> 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  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*
>>>
>>>
>>> {{ question.question_text }}
>>> 
>>> {% 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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+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/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.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+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/CAHn91ocSHH40kRXexvZJ-QzPLXHUGzZy3ZSJg1LtWPQk6DR9XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-14 Thread Mayur Bagul
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  > 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*
>>
>>
>> {{ question.question_text }}
>> 
>> {% 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...@googlegroups.com .
>> To post to this group, send email to django...@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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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+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/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-14 Thread Mayur Bagul
Hello vineeth,

thanks for information. u missed to mention about why we passing Question 
class and primary key in get_object_or_404() ? 
How passing such arguments gonna work? 

On Sunday, April 14, 2019 at 1:25:13 PM UTC+5:30, vineeth sagar wrote:
>
> Hi Mayur,
>
> get_object_or_404, returns an object if it exists in the database or it 
> will raise a 404 exception. So if the object is in the DB, django render 
> template is done, in your case detail.html is rendered with the context 
> dictionary.If there's no row peertaining to the query, then Http404  is 
> raised. So django exception handling kicks in and based on the error code 
> and your debug parameter a particular template is selected.
>
> regards
> Vineeth
>
> On Sun, 14 Apr 2019, 13:16 Mayur Bagul, > 
> 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*
>>
>>
>> {{ question.question_text }}
>> 
>> {% 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...@googlegroups.com .
>> To post to this group, send email to django...@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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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+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/cce00cc0-35bd-4275-bb64-78073032966f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-14 Thread gulam rabbani
It will give you to fetch the id ! Until end of the id

On Sun, 14 Apr, 2019 at 1:47 PM, Mayur Bagul  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*
>
>
> {{ question.question_text }}
> 
> {% 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 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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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+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/CACEi3GP1WYv2zQiuVfxmv7XtZfSR3oQnxQpWjLV%3DsEg%2BOSNNYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-14 Thread vineeth sagar
Hi Mayur,

get_object_or_404, returns an object if it exists in the database or it
will raise a 404 exception. So if the object is in the DB, django render
template is done, in your case detail.html is rendered with the context
dictionary.If there's no row peertaining to the query, then Http404  is
raised. So django exception handling kicks in and based on the error code
and your debug parameter a particular template is selected.

regards
Vineeth

On Sun, 14 Apr 2019, 13:16 Mayur Bagul,  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*
>
>
> {{ question.question_text }}
> 
> {% 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 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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.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+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/CAMMZq8PCxZC2ydA-ja%2BR34yhXcONbBv%2BvFgQ3DEyXJj5dqHAXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How this Line of code works

2019-04-14 Thread Mayur Bagul
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*


{{ question.question_text }}

{% 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 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/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.