Skip to content

Commit b836c52

Browse files
committed
Docs: Documented how to remove the admin action.
1 parent 81b8fdc commit b836c52

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed
24.4 KB
Loading

docs/configuration.txt

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ classes you defined::
4646
urlpatterns += patterns('',
4747
(r'^authority/', include('authority.urls')),
4848
)
49+
50+
If you're using Django 1.1 and Django's admin interface, make sure you place
51+
``authority.autodiscover()`` **before** ``admin.autodiscover()``::
52+
53+
authority.autodiscover()
54+
admin.autodiscover()
4955

56+
This is because django-authority automatically adds a `site-wide action`_ to the
57+
admin-site and it prevents errors if you later decide to remove this action.
58+
See :ref:`handling-admin` how to remove the admin action.
5059

5160
That's all (for now).
61+
62+
.. _site-wide action: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/

docs/handling_admin.txt

+45-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,48 @@
44
Handling permissions using Django's admin interface
55
===================================================
66

7-
*to be written*
7+
*to be written*
8+
9+
Apply permissions using Django's admin actions
10+
==============================================
11+
12+
.. note:: Django admin actions are available in Django 1.1 or later.
13+
14+
.. image:: .static/admin-action-permission.png
15+
16+
Disable the admin action site-wide
17+
----------------------------------
18+
19+
To disable the action site-wide, place this line somewhere in your code.
20+
One of your app ``admin.py`` files might be a good place::
21+
22+
admin.site.disable_action('edit_permissions')
23+
24+
Further informations are available in Django's documentation:
25+
`Disabling a site-wide action`_. If you encounter an error like::
26+
27+
Exception Type: KeyError at /admin/weblog/entry/
28+
Exception Value: 'edit_permissions'
29+
30+
Make sure you placed ``authority.autodiscover()`` before ``admin.autodiscover()``.
31+
See :ref:`configuration` for details.
32+
33+
.. _Disabling a site-wide action: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#disabling-a-site-wide-action
34+
35+
Disable the admin action per ModelAdmin instance
36+
------------------------------------------------
37+
38+
In case you want to disable the permission action per ModelAdmin, delete this
39+
action within the ``get_actions`` method. Here is an example::
40+
41+
class EntryAdmin(admin.ModelAdmin):
42+
43+
def get_actions(self, request):
44+
actions = super(EntryAdmin, self).get_actions(request)
45+
del actions['edit_permissions']
46+
return actions
47+
48+
Further informations are available in Django's documentation:
49+
`Conditionally enabling or disabling actions`_.
50+
51+
.. _Conditionally enabling or disabling actions: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#conditionally-enabling-or-disabling-actions

0 commit comments

Comments
 (0)