Задать вопрос

Тел: +7 965 3737 888

489

Просмотров

3

Ответов

Global custom permissions (no model association)

<p>Example (in project/application/models.py):</p>
register_custom_permissions_simple((("is_editor", "User is editor"),))

<p>In a view:</p>
if not request.user.has_perm('application.is_editor'):
   return HttpResonseRedirect(LoginUrl)

Вопрос полезен? Да0/Нет0
file_4213.py(3.2Кб)
None

Ответы (3):

Ответakaihola:07.10.2010
Ответ полезен? Да0/Нет0

For better Google hits, some keywords related to this snippet: per-app custom permissions, app-wide custom permissions, app-specific custom permissions,

Ответjjlorenzo:14.12.2008
Ответ полезен? Да0/Нет0

pigletto your wrong is a function receives a param, and the param is passed in the form of: foo((2,3),2) the first param of foo is (2,3) that's a tuple

Ответpigletto:27.08.2007
Ответ полезен? Да0/Нет0

Examples are wrong because as it is said just before, 'permissions is a tuple' so instead: register_custom_permissions(('my_perm', 'My Permission'), app) you should use: register_custom_permissions((('my_perm', 'My Permission'),), app)