Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » from a template how to access the request object [RSS Feed]

#1 June 23, 2010 20:04:51

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

from a template how to access the request object


Hi all.

>From a template suppose base.html in your templates how do I access
the request object without actually passing it via the view. Cause I
can access the user object using {{ user }} but I can't access the
get_full_path using something like {{ request.get_full_path }}

Any thoughts?

Nathan.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 23, 2010 20:34:52

Karen T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

from a template how to access the request object


On Wed, Jun 23, 2010 at 3:04 PM, thusjanthan <thusjant...@gmail.com> wrote:

> From a template suppose base.html in your templates how do I access
> the request object without actually passing it via the view. Cause I
> can access the user object using {{ user }} but I can't access the
> get_full_path using something like {{ request.get_full_path }}
>
> Any thoughts?
>

Sounds like you are using a RequestContext, which is the first step. That
plus having the auth context processor listed in the
TEMPLATE_CONTEXT_PROCESSORS setting would give you a template variable user.
(The auth context processor is included in the default setting value for
TEMPLATE_CONTEXT_PROCESSORS.)

The context processor that would set request is this one:http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request.
That one is not in the default TEMPLATE_CONTEXT_PROCESSORS setting, so if
you want request to be set in all your templates then you'll need to add it.

Karen
--http://tracey.org/kmt/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » from a template how to access the request object [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support