Closed saber-solooki closed 7 years ago
Can you rephrase or re-edit your question not sure I can follow?
Sorry I couldn't understand well and after asking for clarification I haven't got yet an answer, please re-open if you still having this issue and provide better info i.e: "for example my JWT has user_id" ? jwt doesn't contain that, so please clarify for next time :D
@saber-solooki I think I am following what your question was. You want to get the instance of the user from the ID and not from the Username, however you cannot get an instance of the user without hitting the DB unless you have an instance of that User living in memory. In which you could index into that data store by the user_id
. Also, looking up a User by user_id should be O(1).
Hi. I read this issue and still I have some question. How can I do some updating user query without hitting DB for getting user instance? for example my JWT has user_id already inside token. I want to update email field of user and I can do this like this:
User.objects.filter(id=user_id).update(email="example@test.com")
,but DRF by default hitting DB and get user instance when send request and we can get user instance like this: request.user. How I can change this behavior and avoiding hitting DB for getting user instance because we already have user_id and can do some stuff with it. thank's