How can I get the current user when dealing with a Django InlineFormset
And the long story in short. Just use the session variable when the user logs in.
def login(request):
#your code here
request.session['userID']=the_user_id
.
.
#rest of your code
Now you can use this id in any view or template. Like
#in any other view
def myview(request):
user_id=request.session['userID']
#rest of your code
#in template
You can directly use the userID in templates like
{{request.session.userID}}
OR
you can make a global variable in DOM for javascript use
<script>
window.userID={{request.session.userID}};
//use userID variable anywhere in DOM
</script>