New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'ObjectPermissionBackend' object has no attribute 'get_user' #46
Comments
I think you are meant to pass in an explicit backend, if the first one does not work. Closing. Django code reference: https://github.com/django/django/blob/59bbacf88db1b533ae05ea38e01b5e1ec9f59622/django/test/client.py#L628-L632 |
I think this should be added to the documentation, this is quite confusing. |
@orf |
Reopening to have the issue as a reminder to investigate whether adding get_user to the backend breaks other stuff, as that would be the proper "fix" here. |
I don't think that's a good idea, I think it's a Django problem. Instead of blindly getting the first auth backend it should be a little smart and skip ones without a |
Hmm, yeah, I went through Django's code and it seems it's not a good idea -- you'd Agreed, the proper way forward is documenting it here and raising an issue with Django. |
I've made a ticket on the Django bug tracker: https://code.djangoproject.com/ticket/27542#ticket PR #47 adds a note to the readme about this. |
Awesome, it got fixed in Django: django/django@47744a0. |
I am trying to use Django's
Client.force_login
during tests, which appears to trigger anAttributeError
when usingObjectPermissionBackend
insettings.AUTHENTICATION_BACKENDS
:The pytest test looks like this:
Setting a password and using
login
works:According to the documentation the
get_user
method is required:https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#writing-an-authentication-backend.
The text was updated successfully, but these errors were encountered: