Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can access the current user, and so their session using threadlocals middleware</p> <p><a href="http://code.arcs.org.au/gitorious/django/django-andsome/blobs/ee8447e3dad2da9383ff701ec640b44cd50d2b0a/middleware/threadlocals.py" rel="nofollow noreferrer">http://code.arcs.org.au/gitorious/django/django-andsome/blobs/ee8447e3dad2da9383ff701ec640b44cd50d2b0a/middleware/threadlocals.py</a></p> <p>but keep in mind:</p> <p><a href="http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser" rel="nofollow noreferrer">http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser</a></p> <p>There might be better solutions to your problem. Maybe you'd like to elaborate why you need request.session on model level?</p> <p><strong>UPDATE:</strong></p> <p>since you explicitly call some method - probably from a view - why don't you just put the <code>request.user</code> as parameter to your <code>html</code> method?</p> <p>models.py:</p> <pre><code>def html(self, user): your code... </code></pre> <p>views.py:</p> <pre><code>yourmodel.html(request.user) </code></pre> <p><strong>UPDATE to your MEGA UPDATE</strong>:</p> <p>This is exactly what {% include %} is for:</p> <p>in your first template do this:</p> <pre><code>{% for discussion in discussions %} {% include "discussion.html" }} {% endfor %} </code></pre> <p>and the second template has request.user.id in its namespace:</p> <pre><code>{% if request.session.user.id not in discussion.users_voted %} user not in list! {% endif %} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload