Skip to content

Commit 60d6252

Browse files
committed
resolve readme comments
1 parent e3f9058 commit 60d6252

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,31 @@ The order of the groups is determined by the order of the individual actions: th
117117

118118
## Simpler `SimpleListFilter`s
119119

120-
Django allows to add extra filters on the Django admin, but even with a `SimpleListFilter`, there are cumbersome to make. We define a `ChoiceListFilter` which can be
121-
used to make these based on a dictionary, and add a function `adminfilter_factory(..)` to define such classes in a more covenient way.
120+
Django allows to add extra filters on the Django admin, but even with a `SimpleListFilter`, they are cumbersome to make. We define a `ChoiceListFilter` which can be
121+
used to make these based on a dictionary, and add a function `adminfilter_factory(..)` to define such classes in a more convenient way.
122122

123123
Once can define such simple list filter by working with a dict like:
124124

125-
```
125+
```python3
126126
from django.db.models import Q
127-
from django.db.modles.functions import Now
127+
from django.db.models.functions import Now
128+
from django_adminlink.admin import ChoiceListFilter
128129

129130
class ArchiveStatusFilter(ChoiceListFilter):
130131
title = 'Archive status'
131132
parameter_name = 'archive_status'
132133
choices = {
133-
'active': ('Active', ~Q(archived_at__lte=Now()))
134+
'active': ('Active', ~Q(archived_at__lte=Now())),
134135
'archived': ('Archived', Q(archived_at__lte=Now()))
135136
}
136137
```
137138

138-
so a dictionary that maps the key of the filter on a 2-tuple with the verbose name as first item, and the Django filter (a `Q` object) as second one. Because it is a dictionary, it is also imppsible to specify the same key twice.
139+
so a dictionary that maps the key of the filter on a 2-tuple with the verbose name as first item, and the Django filter (a `Q` object) as second one. Because it is a dictionary, it is also impossible to specify the same key twice.
139140

140141
We can also define this with the `adminfilter_factory(..)` as follows:
141142

142143

143-
```
144+
```python3
144145
ARCHIVE_OPTIONS = [
145146
('active', 'Active', ~Q(archived_at__lte=Now())),
146147
('archived', 'Archived', Q(archived_at__lte=Now()))

0 commit comments

Comments
 (0)