3๐
โ
I found the answer. Just modify (temporarily) the code of backends.py:
--- django/contrib/auth/backends.py (Revision 17045)
+++ django/contrib/auth/backends.py (Arbeitskopie)
@@ -43,6 +43,9 @@
return user_obj._perm_cache
def has_perm(self, user_obj, perm):
+ all_perms=[u'%s.%s' % (ct, name) for ct, name in Permission.objects.values_list('content_type__app_label', 'codename')]
+ if not perm in all_perms:
+ raise Exception('Permission %s does not exist. foo permissions: %s' % (perm, [p for p in all_perms if 'foo' in p]))
if not user_obj.is_active:
return False
return perm in self.get_all_permissions(user_obj)
๐คguettli
2๐
well i guess you could look at all defined permissions:
from django.contrib.auth.models import Permission
perms = ['%s.%s' % (p.content_type.app_label, p.codename)
for p in Permission.objects.all()]
>>> 'foo.bar' in perms
False
๐คsecond
- [Django]-Got InvalidClientIdError (invalid_request) Mismatching redirect URI. using requests_oauthlib
- [Django]-AWS Elastic Beanstalk Django โ What happens first when deploying to EB, pip install -r requirements.txt or commands in configuration file
Source:stackexchange.com