2👍
✅
I believe the image will be uploaded by authenticated user,right? I mean only after login, he/she can upload image.
In that case you can simply use request.user
in your user parameter.
if form.is_valid():
user_image = form.save(commit=False)
user_image.user_id = request.user.id
user_image.save()
Source:stackexchange.com