You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-3Lines changed: 32 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,14 +33,31 @@ From the trash can in Wagtail admin it's then possible to permanently delete the
33
33
If the parent of the deleted page is either in the trash can or permanently deleted it's still possible to restore the pages by supplying an alternate parent.
34
34
35
35
36
-
## Caveats
36
+
## Usage
37
37
38
+
### App order
38
39
Since Wagtail Trash uses the hook `before_delete_page` it might interfere with your applications `before_delete_page` if you have defined one that returns a status code. Make sure wagtail trash is the last hook that runs otherwise or your custom `before_delete_page` might not run since Wagtail Trash doesn't call it.
39
40
41
+
```python
42
+
# Example
43
+
INSTALLED_APPS= [
44
+
"wagtail.sites",
45
+
"wagtail",
46
+
"wagtail.contrib.forms",
47
+
"wagtail.contrib.redirects",
48
+
"wagtail_modeladmin",
49
+
"wagtail.contrib.routable_page",
50
+
"wagtail.contrib.settings",
51
+
"wagtail_trash", # Import here
52
+
...
53
+
]
54
+
```
55
+
56
+
### Page manager
40
57
Also, Wagtail Trash "deletes" pages by unpublishing them, so if you use a queryset that doesn't filter out unpublished pages, pages in trash can might show up. There is a manager that will fix this for you included, example:
41
58
42
59
```python
43
-
from wagtail.core.models import Page, PageManager
60
+
from wagtail.models import Page, PageManager
44
61
from wagtail_trash.managers import TrashManager
45
62
46
63
classSomePage(Page):
@@ -51,7 +68,19 @@ class SomePage(Page):
51
68
SomePage.objects_excluding_trash.all()
52
69
```
53
70
54
-
Permissions: If you remove a page under a restricted area, this page will be moved and therefore get new permissions. A user might go from not being allowed to see pages under e.g. "Secret Page", but when a page under this area is moved to trash can, the permissions from "Secret Page" are gone so now the user will see it in the trash can.
71
+
### Exclude from sitemap
72
+
Add SkipSitemapIfInTrashMixin if you want trashed pages to be excluded from sitemap.
73
+
74
+
```python
75
+
from wagtail.models import Page
76
+
from wagtail_trash.mixins import SkipSitemapIfInTrashMixin
77
+
78
+
classSomePage(SkipSitemapIfInTrashMixin, Page):
79
+
...
80
+
```
81
+
82
+
### Permissions
83
+
If you remove a page under a restricted area, this page will be moved and therefore get new permissions. A user might go from not being allowed to see pages under e.g. "Secret Page", but when a page under this area is moved to trash can, the permissions from "Secret Page" are gone so now the user will see it in the trash can.
55
84
This is a solvable issue and will be fixed in a later version.
0 commit comments