本文整理汇总了Python中models.Feed.group_feed方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.group_feed方法的具体用法?Python Feed.group_feed怎么用?Python Feed.group_feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.group_feed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_feed
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import group_feed [as 别名]
def api_feed(request):
api_result = {"api": "feed", "status": "success"}
try:
token = request.GET["token"]
user = get_user_from_token(token)
group_id = 0
try:
group_id = request.GET["group_id"]
except:
pass
page = 1
try:
page = int(request.GET["page"])
except:
pass
page_size = 10
try:
page_size = int(request.GET["page_size"])
except:
pass
if not user:
api_result["status"] = "failure"
api_result["error"] = "user not found"
else:
if group_id == 0:
polls = Feed.user_feed(user, page, page_size)
else:
polls = Feed.group_feed(user, group_id, page, page_size)
if page == 1 and not polls:
# create_feed_new_user(user)
# polls = Feed.user_feed(user, page, page_size)
pass
if polls:
api_result["polls"] = json_polls(polls)
else:
api_result["polls"] = "None"
except Exception as e:
api_result["status"] = "failure"
api_result["error"] = e.message
pass
return JsonResponse(api_result)