Skip to content

Instantly share code, notes, and snippets.

@evildmp
Created November 22, 2018 14:55
Show Gist options
  • Select an option

  • Save evildmp/b32d7f3b8038c4e2ee8cd28d28809a91 to your computer and use it in GitHub Desktop.

Select an option

Save evildmp/b32d7f3b8038c4e2ee8cd28d28809a91 to your computer and use it in GitHub Desktop.
Delete all pages in site(s)
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