1👍
✅
This happens when user is not logged in.
request.user
by default is a SimpleLazyObject
which evaluates to the logged in user, if user is logged in. If not, it evaluates to AnonymousUser
hence the error.
Source:stackexchange.com