Skip to content

Commit fffde8a

Browse files
committed
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)
1 parent 3b00824 commit fffde8a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rest_framework/throttling.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class UserRateThrottle(SimpleRateThrottle):
191191

192192
def get_cache_key(self, request, view):
193193
if request.user.is_authenticated():
194-
ident = request.user.id
194+
ident = request.user.pk
195195
else:
196196
ident = self.get_ident(request)
197197

@@ -239,7 +239,7 @@ def get_cache_key(self, request, view):
239239
with the '.throttle_scope` property of the view.
240240
"""
241241
if request.user.is_authenticated():
242-
ident = request.user.id
242+
ident = request.user.pk
243243
else:
244244
ident = self.get_ident(request)
245245

0 commit comments

Comments
 (0)