views.py 文件源码

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

项目:API-Manager 作者: OpenBankProject 项目源码 文件源码
def get_context_data(self, **kwargs):
        context = super(DetailView, self).get_context_data(**kwargs)
        # NOTE: assuming there is just one user with that email address
        # The API needs a call 'get user by id'!
        user = {}
        try:
            urlpath = '/users/user_id/{}'.format(self.kwargs['user_id'])
            user = self.api.get(urlpath)
            context['form'].fields['user_id'].initial = user['user_id']
        except APIError as err:
            messages.error(self.request, err)

        context.update({
            'apiuser': user,  # 'user' is logged-in user in template context
        })
        return context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号