小编sau*_*abh的帖子

django跟踪最近的在线用户

有没有办法跟踪django中的活跃用户?

我已经看到了一些问题的在线解决方案:

http://mpcabd.igeex.biz/get-online-users-in-django/

成为其中之一.但修改模型结构只是为了解决这个简单问题似乎很奇怪.我想知道是否有任何快速解决方案.

django auth中的last_login字段也没什么用处,因为它只记录用户登录的时间,如果用户长时间处于会话状态,则不更新字段

django session

6
推荐指数
1
解决办法
2484
查看次数

在django-sphinx中查询多个索引

django-sphinx文档显示django-sphinx层还支持对多个索引进行一些基本查询.

http://github.com/dcramer/django-sphinx/blob/master/README.rst

from djangosphinx.models import SphinxSearch

SphinxSearch('index1 index2 index3').query('hello')
Run Code Online (Sandbox Code Playgroud)

似乎SphinxSearch不包含函数query().我还尝试在spinx.conf sql_query配置中包含content_type,如django-sphinx文档中所述.没有任何效果.

Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'SphinxSearch' object has no attribute 'query'
Run Code Online (Sandbox Code Playgroud)

任何人都可以了解如何从sphinx中的多个索引中获得排名结果

django full-text-search django-sphinx

1
推荐指数
1
解决办法
1879
查看次数

根据键值过滤python中的嵌套字典

如何根据键值过滤python中的嵌套字典:

d = {'data': {'country': 'US', 'city': 'New York', 'state': None},
     'tags': ['US', 'New York'],
     'type': 'country_info',
     'growth_rate': None
     }
Run Code Online (Sandbox Code Playgroud)

我想过滤这个字典以消除NoneType值,因此产生的字典应该是:

d = {'data': {'country': 'US', 'city': 'New York'},
     'tags': ['US', 'New York'],
     'type': 'country_info',
     }
Run Code Online (Sandbox Code Playgroud)

此外,dict可以有多个嵌套级别.我想从dict中删除所有NoneType值.

python dictionary

1
推荐指数
1
解决办法
2668
查看次数