def api_quota(self):
'''Get's the amount of requests this user has made in the last 24
hours as well as the maximum allowed by DRF's throttling framework'''
hits = cache.get('throttle_user_{0}'.format(self.user.id))
used = len(hits) if hits else 0
allowed = settings.REST_FRAMEWORK['DEFAULT_THROTTLE_RATES']['user']
return {'used': used, 'allowed': allowed}
评论列表
文章目录