[Answer]-Django "Manager isn't accessible via User instance"

1👍

You have error in these lines

User = request.user
edit1 = User.objects.get(user_id=user)

Probably you mistakenly defined variable User (with uppercase ‘U’) and you should be checking against id not user_id.

You would want to change it to

user = request.user
edit1 = User.objects.get(id=user.id)

or better don’t define directly use request.user

edit1 = User.objects.get(id=request.user.id)

Or even better don’t fetch from DB, you can directly use object in request.user

edit1 = request.user
👤Rohan

Leave a comment