Zcentric

@Mike Zupan · May 12, 2010 · 1 min read

Django fix for ‘User’ object has no attribute ‘backend

I was trying to auto login a user if I had their user object and was getting this error when I just called something like

login(request, user)

Well this is due to Django wanting to make sure you auth the user first. If you want to bypass this you can just use the following before login

user.backend = 'django.contrib.auth.backends.ModelBackend'

This might not be the best solution but it works