Created
November 22, 2018 14:55
-
-
Save evildmp/b32d7f3b8038c4e2ee8cd28d28809a91 to your computer and use it in GitHub Desktop.
Delete all pages in site(s)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from cms.models import Page | |
| pages = ( | |
| Page | |
| .objects | |
| .filter(node__site_id__in=[28, 15], node__depth=1) # Important! Make sure the site_id values are correct... | |
| .select_related('node') | |
| .distinct() | |
| .order_by('node__path') | |
| ) | |
| total = pages.count() | |
| print('{} pages remaining'.format(total)) | |
| for idx, page in enumerate(pages, start=1): | |
| print('{}/{}'.format(idx, total)) | |
| print(page.delete()) | |
| print('-' * 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment