Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is in response to Balon's query:</p> <p>Yes, with around 140k sessions to iterate through I can see why Harold's answer may not be as fast as you may like!</p> <p>The way I would recommend is to add a model whose only two properties are foreign keys to <code>User</code> and <code>Session</code> objects. Then add some middleware that keeps this model up-to-date with current user sessions. I have used this sort of setup before; in my case, I borrowed the <code>sessionprofile</code> module from this <a href="http://code.google.com/p/django-login-for-phpbb/">Single Sign-On system for phpBB</a> (see the source code in the "django/sessionprofile" folder) and this (I think) would suit your needs.</p> <p>What you would end up with is some management function somewhere in your code like this (assuming the same code names and layout as in the <code>sessionprofile</code> module linked above):</p> <pre><code>from sessionprofile.models import SessionProfile from django.contrib.auth.models import User # Find all SessionProfile objects corresponding to a given username sessionProfiles = SessionProfile.objects.filter(user__username__exact='johndoe') # Delete all corresponding sessions [sp.session.delete() for sp in sessionProfiles] </code></pre> <p>(I think this will also delete the <code>SessionProfile</code> objects, as from what I recall, Django's default behaviour when an object referenced by a <code>ForeignKey</code> is deleted is to cascade it and also delete the object containing the <code>ForeignKey</code>, but if not then it is trivial enough to delete the contents of <code>sessionProfiles</code> when you are done.)</p>
    singulars
    1. This table or related slice is empty.
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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