在后端显示模板上的确认消息(python / Django)

时间:2015-11-17 08:30:52

标签: python angularjs django twitter-bootstrap

您好JSONResponseMixin View,此视图的主要功能是在用户点击GUI确认后将状态更改为已确认。我想显示一个弹出窗口,说明它已经确认。我怎么能从django views.py?

那样做

以下是我的观点

class ConfirmView(JSONResponseMixin, View):

    def post(self, request, *args, **kwargs):
        status = 'error'
        msg = "this is from me"
        post_body = json.loads(self.request.body)
        fab_value = post_body['fab']
        mast_value = post_body['mast']
        comment = post_body.get('comment')

        try:
           object = Forecast.objects.get(fab=fab_value, mast=mast_value, type='XC')
        except ObjectDoesNotExist:
            object = []
        else:
            if object.status == 'notified(created)' or 'notified(updated)':
                object.status = 'confirmed'
                object.comment = second_po_comment
                object.confirm = self.request.user
                object.modified_by =User.objects.get(username=self.request.user.username)
                object.save()

        return self.render_json_response(dict(status=status, msg=msg))

0 个答案:

没有答案