Commit fffde8a6 by Kaptian

Update throttling.py

Use pk pseudo attribute for identifying the user (in case the user model is not the default and has a different column name for the unique id)
parent 3b008245
...@@ -191,7 +191,7 @@ class UserRateThrottle(SimpleRateThrottle): ...@@ -191,7 +191,7 @@ class UserRateThrottle(SimpleRateThrottle):
def get_cache_key(self, request, view): def get_cache_key(self, request, view):
if request.user.is_authenticated(): if request.user.is_authenticated():
ident = request.user.id ident = request.user.pk
else: else:
ident = self.get_ident(request) ident = self.get_ident(request)
...@@ -239,7 +239,7 @@ class ScopedRateThrottle(SimpleRateThrottle): ...@@ -239,7 +239,7 @@ class ScopedRateThrottle(SimpleRateThrottle):
with the '.throttle_scope` property of the view. with the '.throttle_scope` property of the view.
""" """
if request.user.is_authenticated(): if request.user.is_authenticated():
ident = request.user.id ident = request.user.pk
else: else:
ident = self.get_ident(request) ident = self.get_ident(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment