models.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:akamatsu 作者: rmed 项目源码 文件源码
def before_page_insert(mapper, connection, page):
    """Perform actions before a page is first created.

    These include:
        - Slugify the title of the page if no slug is provided.
        - Set the route of the page.
    """
    # Slug
    if not page.slug:
        page.slug = slugify.slugify(page.title, to_lower=True, max_length=255)

    # Route
    if page.is_root:
        # Root page
        page.route = '/'

    else:
        slash = '' if page.base_route.endswith('/') else '/'
        page.route = page.base_route + slash + page.slug
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号