Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4259 closed (invalid)

Using sessions out of views Is Incomplete / Unusable

Reported by: pkenjora@… Owned by: jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The example does not address how to get the session_key for the session from which the tag is being called. This component is critical yet missing. Would make the docs much better if the example included how to get the session_key ourside a view. Sorry couldnt figure it out otherwise I would have added a solution.

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Not exactly sure what you mean by getting the session key for the session from which the tag is being called. Could you please explain.

comment:2 Changed 7 years ago by Simon G. <dev@…>

If you want to get the session ID in a view, then if SessionMiddleware is enabled, then you can look inside request.session for the key (session_key), and then query the Session table for the information. See Session Docs for more info.

comment:3 Changed 7 years ago by ubernostrum

I assume you're talking about doing this in a template tag; template tags have access to the template context, and if you add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS setting, the request (and therefore request.session will be available in the context.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.