I have an app called forms_and_models that I use for study. In the Django 1.7 documentation says:
Assuming you have an application whose app_label is foo and a template called Bar , to test basic permissions, you should use:
- to add:
user.has_perm('foo.add_bar')
- to change:
user.has_perm('foo.change_bar')
- to delete:
user.has_perm('foo.delete_bar')
Through the admin, I've added the permission: forms_and_models | author | Can add author to my user. Following the documentation template, I deduced that to test if a user has permission to add an author, I could run the following code:
"""O usuário abaixo existe e é o que eu configurei a permissão acima"""
user = User.objects.get(username='junior')
user.has_perm('forms_and_models.add_author')
However, this line of code always returns false. What am I letting go unnoticed about the permissions system?