| 1 |
from django.conf import settings |
| 2 |
from django.core.checks import Tags, Warning, register |
| 3 |
|
| 4 |
|
| 5 |
# noinspection PyUnusedLocal |
| 6 |
@register(Tags.compatibility) |
| 7 |
def check_settings(app_configs, **kwargs): |
| 8 |
"""Check that settings are implemented properly |
| 9 |
:param app_configs: a list of apps to be checks or None for all |
| 10 |
:param kwargs: keyword arguments |
| 11 |
:return: a list of errors |
| 12 |
""" |
| 13 |
checks = [] |
| 14 |
if "guardian.backends.ObjectPermissionBackend" not in settings.AUTHENTICATION_BACKENDS: |
| 15 |
msg = ( |
| 16 |
"Guardian authentication backend is not hooked. You can add this in settings as eg: " |
| 17 |
"`AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', " |
| 18 |
"'guardian.backends.ObjectPermissionBackend')`." |
| 19 |
) |
| 20 |
checks.append(Warning(msg, id="guardian.W001")) |
| 21 |
return checks |