Skip to content

Commit 2e315e4

Browse files
committed
update doc
1 parent 9c7bc8a commit 2e315e4

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ You can install the package with:
1919
pip install django-adminlink
2020
```
2121

22+
You do *not* need to add `'django_adminlink'` to the `INSTALLED_APPS` settings *unless*, you use the `SingleItemActionMixin` or a derived product from it, since then
23+
you need to make use of the `static/js/single_admin_action.js` file that ships with it. So then the `INSTALLED_APPS` looks like:
24+
25+
```python3
26+
# settings.py
27+
28+
#
29+
30+
INSTALLED_APPS = [
31+
# …,
32+
'django_adminlink'
33+
]
34+
```
35+
2236
## Usage
2337

2438
Once the package is installed, we can work with the mixins provided by the package.

django_adminlink/models.py

Whitespace-only changes.

docs/source/getting_started.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ Once the package is installed, you can use the `LinkFieldAdminMixin` mixin in th
1414
list_display = ['__str__', 'genre']
1515
1616
If `genre` is a `ForeignKey` to a `Genre` model for example, and `Genre` has its own `ModelAdmin`, it will automatically convert `genre` into a column that adds a link to the admin detail view of the corresponding genre.
17+
18+
19+
Another option is to use with the `SingleItemActionMixin` to add a button per row to do (one or more) actions for that specific line with:
20+
21+
..code-block:: python3
22+
23+
from django.contrib import admin
24+
from django_adminlink.admin import SingleItemActionMixin
25+
26+
@admin.register(Movie)
27+
class MovieAdmin(SingleItemActionMixin, admin.ModelAdmin):
28+
action_buttons = {'delete': 'delete_selected'}
29+
30+
here the `action_buttons` is a dictionary (or list) of labels that map to the admin actions. If the label is the same for each admin action, you can use a list, where you thus list the label and admin action only once.

docs/source/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ The package can be fetched as `django-adminlink`, so for example with `pip` with
88
99
pip3 install django-adminlink
1010
11-
The item is not a Django app, so one should *not* to include it in the `INSTALLED_APPS`. It is only a module that
12-
offers some functionality to use in Django applications.
11+
The item is a Django app, but you do not per se have to install it as such. If you don't make use of the `SingleItemActionMixin`,
12+
you don't need to add `'django_adminlink'` to the `INSTALLED_APPS`, otherwise you need to do this to include the static file.

0 commit comments

Comments
 (0)