Re: how to use view function in another function of view in django

2016-06-16 Thread 'Abraham Varricatt' via Django users
I'm going to go out and make a random guess that when you say "use a view 
inside another view" with respect to the code you posted, you want all 
calls to index() or list() to render the base view. In that case just use 
return. i.e.

def index(request):
  return base(request)

Yours,
Abraham V.




On Wednesday, June 15, 2016 at 11:24:18 PM UTC+5:30, hossein wrote:
>
> def base(request):
> j=Job.objects.all()
> a=Ab.objects.all()
> return render(request,'base.html',{'j':j, 'a':a})
>
> def index(request):
> base(request)
> x=X.objects.all()
> return render(request, 'index.html',{'x':x})
>
> def list(request):
> base(request)
> z=Z.objects.all()
> return render(request, 'list.html',{'z':z})
>
>

-- 
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/8330c99d-59ba-45da-b500-b2c40ed95daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-16 Thread ludovic coues
I don't understand what you are trying to do.
base(request) create a response for the browser using j and a to
render base.html.
If you want to have access to j and a in both index.html and
list.html, try this:

def base(request):
j = Job.objects.all()
a = Ab.objects.all()
return {'j':j, 'a':a}

def index(request):
context = base(request)
context['x'] = X.objects.all()
return render(request, 'index.html', context)


2016-06-16 2:22 GMT+02:00 hossein :
> More Explain Please
>
>
> On Thursday, June 16, 2016 at 3:13:38 AM UTC+4:30, Gergely Polonkai wrote:
>>
>> Just like this. Unless you have a specific use case you forgot to share in
>> your mail.
>>
>> Views are mere functions that get called with a request az a parameter.
>> You shouldn’t treat them as special/holy/uncallable.
>>
>> Best,
>> Gergely
>>
>> On Jun 15, 2016 19:56, "hossein"  wrote:
>>>
>>> def base(request):
>>> j=Job.objects.all()
>>> a=Ab.objects.all()
>>> return render(request,'base.html',{'j':j, 'a':a})
>>>
>>> def index(request):
>>> base(request)
>>> x=X.objects.all()
>>> return render(request, 'index.html',{'x':x})
>>>
>>> def list(request):
>>> base(request)
>>> z=Z.objects.all()
>>> return render(request, 'list.html',{'z':z})
>>>
>>> --
>>> 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/3cc2651c-35df-4eaf-bab6-b1ae936f73d4%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/72d16e93-10b7-4465-b116-68bf054a89d4%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTasQ6AxFrTvYjCcv5hz5S%2BEGx2Gy%3DmBu7C%3Db44mAk3T8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-15 Thread hossein
More Explain Please

On Thursday, June 16, 2016 at 3:13:38 AM UTC+4:30, Gergely Polonkai wrote:
>
> Just like this. Unless you have a specific use case you forgot to share in 
> your mail.
>
> Views are mere functions that get called with a request az a parameter. 
> You shouldn’t treat them as special/holy/uncallable.
>
> Best,
> Gergely
> On Jun 15, 2016 19:56, "hossein"  wrote:
>
>> def base(request):
>> j=Job.objects.all()
>> a=Ab.objects.all()
>> return render(request,'base.html',{'j':j, 'a':a})
>>
>> def index(request):
>> base(request)
>> x=X.objects.all()
>> return render(request, 'index.html',{'x':x})
>>
>> def list(request):
>> base(request)
>> z=Z.objects.all()
>> return render(request, 'list.html',{'z':z})
>>
>> -- 
>> 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/3cc2651c-35df-4eaf-bab6-b1ae936f73d4%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/72d16e93-10b7-4465-b116-68bf054a89d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-15 Thread Gergely Polonkai
Just like this. Unless you have a specific use case you forgot to share in
your mail.

Views are mere functions that get called with a request az a parameter. You
shouldn’t treat them as special/holy/uncallable.

Best,
Gergely
On Jun 15, 2016 19:56, "hossein"  wrote:

> def base(request):
> j=Job.objects.all()
> a=Ab.objects.all()
> return render(request,'base.html',{'j':j, 'a':a})
>
> def index(request):
> base(request)
> x=X.objects.all()
> return render(request, 'index.html',{'x':x})
>
> def list(request):
> base(request)
> z=Z.objects.all()
> return render(request, 'list.html',{'z':z})
>
> --
> 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/3cc2651c-35df-4eaf-bab6-b1ae936f73d4%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/CACczBULw3kggNH5%3DerHjm5iY6yFkjwEknLL8V9Cpa1N9RX2Cww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.