Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_blog_page(self, slug, title):
# Create blog page
try:
self.blogpage = BlogPage.objects.get(slug=slug)
except BlogPage.DoesNotExist:
# Get root page
rootpage = Page.objects.first()
# Set site root page as root site page
site = Site.objects.first()
site.root_page = rootpage
site.save()
# Get blogpage content type
self.blogpage = BlogPage(title=title, slug=slug)
rootpage.add_child(instance=self.blogpage)
revision = rootpage.save_revision()
revision.publish()