Django ‘AnonymousUser’ object has no attribute ‘_meta’

You already have the user when you save the form, so you don’t need to call authenticate since you already provide the backend when calling login():

user = form.save()
login(request, user, backend='django.contrib.auth.backends.ModelBackend')

Leave a Comment