Hi,
We define the permission like in the docs:
https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#custom-permissionsTo avoid the magic string 'fooapp.fooperm' in the code which uses the permission very often, I choose this solution:
{{{
# file models.py
class FooModel(Model):
FOOPERM_PERMISSION_STRING='fooapp.fooperm'
class Meta:
permissions = (
('fooperm', 'Foo Permission'),
)
}}}
{{{
# file views.py
# This and other files use the permission string very often.
...
if request.user.has_perm(FooModel.FOOPERM_PERMISSION_STRING):
...
}}}
But still I am not happy with the above solution. I think it looks ugly.
How do you avoid the magic permission string in your code?
Regards,
Thomas Güttler