-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow a root page to live under the home page (for now)
- Loading branch information
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import json | ||
from django.core.management.base import BaseCommand | ||
from pages.models import HomePage, RootPage | ||
|
||
|
||
class Command(BaseCommand): | ||
help="Use this to move the pages the currently exist under the home page to the new root. This keeps the homepage under the new root page." | ||
|
||
def handle(self, *args, **options): | ||
try: | ||
root = RootPage.objects.first() | ||
except RootPage.DoesNotExist: | ||
root = RootPage.objects.create(title="Home", slug="home") | ||
|
||
home = HomePage.objects.first() | ||
home.copy(to=root, recursive=True, copy_revisions=True, keep_live=True) | ||
print("All children of the home page have been moved to the new root.") |
This file contains 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