I want to get last inserted id for current user from database.I know i can get last inserted row in a table from this query last_inserted_id = User.objects.order_by(‘-id’)[0]
But if there multiple users who are logged in to site at same time than how can I get the last inserted data for the current user.
To get last inserted data for the current user you should store a reference to the user in each model:
Then you should remember to populate this property when you create a new model.
To retrieve last inserted data for this user:
Perhaps you can authomatize audits in some way. See Full Model History snippet for ideas.