Django: setting a session and getting session key in same view

前端 未结 2 1787
小鲜肉
小鲜肉 2020-12-28 14:53

I want to store some things in a database, and am using the current session as a foreign key: from models.py

class Visited(models.Model):
    session = model         


        
2条回答
  •  被撕碎了的回忆
    2020-12-28 15:46

    if you want to destroy session i would suggest a better idea is first use django shell.

    from django.contrib.sessions.models import Session
    Session.objects.all() #you see all sessions
    Session.objects.all().delete() 
    

    in last query you can filter according to your need. and hit a query

提交回复
热议问题