List Info

Thread: Is there a setting which will provide RequestContext to each view autmatically?




Is there a setting which will provide RequestContext to each view autmatically?
user name
2007-12-16 11:41:46
Since I need my logged in user to be available to each
template, I
need to go and add  context_instance=RequestContext(request)
to each
view. Is there any setting which can make RequestContext
available to
each view?
A related question is, I have some objects I need to make
available to
each page, for example to show in the sidebar. So I need to
call a
method for each of my view to do add these objects, like
...

	payload = {'create_form': create,}
	payload.update(_get_sidebar_objects(request))
        return render_to_response('create.html', payload,
context_instance=RequestContext(request),)

Is there some way I can make some objects avaibale to all
templates?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is there a setting which will provide RequestContext to each view autmatically?
user name
2007-12-16 15:40:55
http://www.django
project.com/documentation/templates_python/#subclassing-cont
ext-requestcontext

On 16 ΔΕΛ, 20:41, shabda <shabda.r...gmail.com> wrote:
> Since I need my logged in user to be available to each
template, I
> need to go and add 
context_instance=RequestContext(request) to each
> view. Is there any setting which can make
RequestContext available to
> each view?
> A related question is, I have some objects I need to
make available to
> each page, for example to show in the sidebar. So I
need to call a
> method for each of my view to do add these objects,
like ...
>
>         payload = {'create_form': create,}
>         payload.update(_get_sidebar_objects(request))
>         return render_to_response('create.html',
payload,
> context_instance=RequestContext(request),)
>
> Is there some way I can make some objects avaibale to
all templates?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is there a setting which will provide RequestContext to each view autmatically?
user name
2007-12-16 15:55:46
from django.views.generic.simple import direct_to_template

view:
   return direct_to_template(request, 'template.htm',
extra_context)

On top of that, use a context_processor (follow alex's
link)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )