Hello.
It is too difficult to give a conclusion with limited information.
Having said that, I think this documentation is very related with your problem.
https://docs.djangoproject.com/en/3.2/topics/auth/default/
Instead of trying to access a user object, You can try to create a new user object with the helper function:
I am not sure about the cause of syntax error, but in the past I had seen a related case, in which someone confused between request , which is a module imported at global level from django.http
, and self.request, an attribute of the view instance.
Hope this helps