From 8c97d40b20a007078393335fe0bf328f77415167 Mon Sep 17 00:00:00 2001 From: liangliangyy Date: Sat, 11 May 2019 22:00:39 +0800 Subject: [PATCH] Fix #260 Fix #262 --- DjangoBlog/utils.py | 9 ++++----- bin/config.md | 6 ++++-- blog/templatetags/blog_tags.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/DjangoBlog/utils.py b/DjangoBlog/utils.py index 75555c7a..48ef1137 100644 --- a/DjangoBlog/utils.py +++ b/DjangoBlog/utils.py @@ -47,24 +47,23 @@ def news(*args, **kwargs): key = view.get_cache_key() except: key = None - pass if not key: unique_str = repr((func, args, kwargs)) m = md5(unique_str.encode('utf-8')) key = m.hexdigest() value = cache.get(key) - if value: + if value is not None: # logger.info('cache_decorator get cache:%s key:%s' % (func.__name__, key)) - if repr(value) == 'default': + if str(value) == '__default_cache_value__': return None else: return value else: logger.info('cache_decorator set cache:%s key:%s' % (func.__name__, key)) value = func(*args, **kwargs) - if not value: - cache.set(key, 'default', expiration) + if value is None: + cache.set(key, '__default_cache_value__', expiration) else: cache.set(key, value, expiration) return value diff --git a/bin/config.md b/bin/config.md index b626333c..76dac74f 100644 --- a/bin/config.md +++ b/bin/config.md @@ -21,8 +21,10 @@ CACHES = { 现在已经支持微博,Google,GitHub,Facebook登录,需要在其对应的开放平台申请oauth登录权限,然后在 **后台->Oauth** 配置中新增配置,填写对应的`appkey`和`appsecret`以及回调地址。 - - +### 回调地址示例: +qq:http://你的域名/oauth/authorize?type=qq +微博:http://你的域名/oauth/authorize?type=weibo +type对应在`oauthmanager`中的type字段。 ## owntracks: owntracks是一个位置追踪软件,可以定时的将你的坐标提交到你的服务器上,现在简单的支持owntracks功能,需要安装owntracks的app,然后将api地址设置为: diff --git a/blog/templatetags/blog_tags.py b/blog/templatetags/blog_tags.py index b7ff3c54..760f8d56 100644 --- a/blog/templatetags/blog_tags.py +++ b/blog/templatetags/blog_tags.py @@ -148,7 +148,7 @@ def load_sidebar(user, linktype): tags = Tag.objects.all() sidebar_tags = None if tags and len(tags) > 0: - s = [t for t in [(t, t.get_article_count()) for t in tags] if t[1] > 0] + s = [t for t in [(t, t.get_article_count()) for t in tags] if t[1]] count = sum([t[1] for t in s]) dd = 1 if (count == 0 or not len(tags)) else count / len(tags) import random