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

May 12, 2010    Django

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



comments powered by Disqus