context_processors.py 文件源码

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

项目:steemprojects.com 作者: noisy 项目源码 文件源码
def lazy_profile(request):
    """
    Returns context variables required by templates that assume a profile
    on each request
    """

    def get_user_profile():
        if hasattr(request, 'profile'):
            return request.profile
        else:
            return request.user.profile

    data = {
        'profile': SimpleLazyObject(get_user_profile),
        }
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号