当前位置: 首页>>代码示例>>Python>>正文


Python response.HttpResponseRedirect方法代码示例

本文整理汇总了Python中django.http.response.HttpResponseRedirect方法的典型用法代码示例。如果您正苦于以下问题:Python response.HttpResponseRedirect方法的具体用法?Python response.HttpResponseRedirect怎么用?Python response.HttpResponseRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http.response的用法示例。


在下文中一共展示了response.HttpResponseRedirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: form_valid

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def form_valid(self, form):
        base, created = BaseKeyword.objects.get_or_create(term=form.cleaned_data['term'])
        keyword = Keyword()
        keyword.base = base
        keyword.project = self.request.project
        try:
            keyword.save()
        except IntegrityError:
            # The unique_together constraint on Keyword model failed
            # TODO: Handle a more specific error, IntegrityError could be raised by things other than duplicate too
            messages.add_message(
                message=_('You already have that keyword for this project, so we did not add it again.'),
                level=messages.INFO,
                request=self.request,
                extra_tags='module-level'
            )
        return HttpResponseRedirect(self.get_success_url()) 
开发者ID:pixlie,项目名称:oxidizr,代码行数:19,代码来源:views.py

示例2: create_admin

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def create_admin(self, request):
        if request.method == 'GET' :
            result = self.usermanager_api.is_has(adminuser)
            if result :
                return HttpResponseRedirect(reverse('login'))
            else :
                return render(request, 'user_create_admin.html')
        else :
            form = Form_Login(request.POST)
            if form.is_valid():
                post_key_list = ['name', 'contact', 'password', 'password-confirm', 'vaultpassword', 'vaultpassword-confirm'] 
                user_mess_dict = {}
                for key in post_key_list :
                    user_mess_dict[key] = request.POST.get(key)
                    
                user_mess_dict['username'] = adminuser
                user_mess_dict['creater'] = adminuser
                
                result = self.usermanager_api.create(user_mess_dict)
                if not result[0] :
                    self.logger.info('超级管理员' + adminuser + '创建失败,原因:' + result[1])
                    return render(request, 'user_create_admin.html', {'error_message' : result[1]})
                else :
                    self.logger.info('超级管理员' + adminuser + '创建成功')
                    return HttpResponseRedirect(reverse('index')) 
开发者ID:lykops,项目名称:lykops,代码行数:27,代码来源:views.py

示例3: detail

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def detail(self, request):
        
        '''
        查看用户的ansible的option数据
        '''
        
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
    
        vault_password = request.session['vault_password']
        result = self.ansible_option_api.detail(username, vault_password)
        if result[0] :
            data = result[1]
            error_message = ''
            self.logger.info(self.username + ' 查看用户' + username + '的ansible配置成功')
        else :
            data = {}
            error_message = self.username + ' 查看用户' + username + '的ansible配置失败,查询时发生错误,原因:' + result[1]
            self.logger.error(error_message) 
            error_message = result[1]
            
        return render_to_response('option_detail.html', {'data':data, 'login_user':username, 'error_message':error_message, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html}) 
开发者ID:lykops,项目名称:lykops,代码行数:27,代码来源:options.py

示例4: summary

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def summary(self, request):
        
        '''
        用户列表
        '''
        
        result = self._is_login(request)
        if not result[0] :
            return HttpResponseRedirect(reverse('login'))
        else :
            username = result[1]
            
        result = self.usermanager_api.summary()

        list_title_list = ['用户', '真实名', '是否激活' , '上次登录时间']
        if result[0] :
            self.logger.info(self.username + ' 获取所有用户信息时成功')
            return render(request, 'user_list.html', {'list_title_list':list_title_list, 'query_list':result[1], 'login_user':username, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            error_message = self.username + ' 获取所有用户信息时失败,原因:' + result[1]
            self.logger.error(error_message)
            return HttpResponseRedirect(reverse('index')) 
开发者ID:lykops,项目名称:lykops,代码行数:24,代码来源:user.py

示例5: detail

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def detail(self, request):
        
        '''
        查看用户详细信息
        '''
        
        result = self._is_login(request)
        if not result[0] :
            return HttpResponseRedirect(reverse('login'))
        else :
            login_name = result[1]
            
        username = request.GET['username']
        result = self.usermanager_api.detail(username)
        if result[0] :
            self.logger.info(self.username + ' 查看用户' + username + '的详细数据成功')
            return render(request, 'user_detail.html', {'username':username, 'detail_dict':result[1] , 'login_user':login_name, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            error_message = self.username + ' 查看用户' + username + '的详细数据,查询失败,原因:' + result[1]
            self.logger.error(error_message)
            return HttpResponseRedirect(reverse('index')) 
开发者ID:lykops,项目名称:lykops,代码行数:23,代码来源:user.py

示例6: delete

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def delete(self, request):
        
        '''
        删除用户
        '''
        
        result = self._is_login(request)
        if result[0] :
            editer = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        username = request.GET.get('username')
                    
        result = self.usermanager_api.delete(username , editer=editer)
        if not result[0] :
            error_message = self.username + ' 删除用户' + username + ',提交失败,原因:' + result[1]
            self.logger.error(error_message)
            http_referer = self.uri_api.get_httpreferer(username, no=-1)
            return render(request, 'result.html', {'error_message' : error_message, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            self.logger.info(self.username + ' 删除用户' + username + '成功,注:实际只是标记为删除并非真实删除')
            return HttpResponseRedirect(reverse('user_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:25,代码来源:user.py

示例7: disable

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def disable(self, request):
        
        '''
        禁用用户登陆
        '''
        
        result = self._is_login(request)
        if result[0] :
            editer = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        username = request.GET.get('username')
                    
        result = self.usermanager_api.disable(username , editer=editer)
        if not result[0] :
            error_message = self.username + ' 禁用用户' + username + ',提交失败,原因:' + result[1]
            self.logger.error(error_message)
            http_referer = self.uri_api.get_httpreferer(username, no=-1)
            return render(request, 'result.html', {'error_message' : error_message, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            self.logger.info(self.username + ' 禁用用户' + username + '成功')
            return HttpResponseRedirect(reverse('user_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:25,代码来源:user.py

示例8: enable

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def enable(self, request):
        
        '''
        允许用户登陆
        '''
        
        result = self._is_login(request)
        if result[0] :
            editer = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        username = request.GET.get('username')
                    
        result = self.usermanager_api.enable(username , editer=editer)
        if not result[0] :
            error_message = self.username + ' 启用用户' + username + ',提交失败,原因:' + result[1]
            self.logger.error(error_message)
            http_referer = self.uri_api.get_httpreferer(username, no=-1)
            return render(request, 'result.html', {'error_message' : error_message, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            self.logger.info(self.username + ' 启用用户' + username + '成功')
            return HttpResponseRedirect(reverse('user_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:25,代码来源:user.py

示例9: summary

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def summary(self, request):
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))

        result = self.inventory_api.summary(username)
        if result[0] :
            title_list = result[1]
            query_list = result[2]
            http_referer = self.uri_api.get_httpreferer(username, no=-1)
            self.logger.info(self.username + ' 查看用户' + username + '的主机列表,查询数据成功')
            return render(request, 'inve_list.html', {'title_list':title_list, 'query_list':query_list, 'login_user':username, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            error_message = self.username + ' 查看用户' + username + '的主机列表失败,查询时发生错误,原因:' + result[1]
            self.logger.error(error_message) 
            http_referer = self.uri_api.get_httpreferer(username, no=-1)
            return render(request, 'result.html', {'error_message' : error_message, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html}) 
开发者ID:lykops,项目名称:lykops,代码行数:21,代码来源:inventory.py

示例10: add

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def add(self, request):
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        if request.method == 'GET' :
            html_code = self.inventory_api.add_get(username)
            return render(request, 'inve_add.html', {'html_code': html_code, 'login_user':username, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else:
            form = Form_Login(request.POST)
            if form.is_valid():
                user_mess_dict = self.post_handle(request)
                vault_password = request.session['vault_password']
                result = self.inventory_api.add_post(username, vault_password, user_mess_dict)
                if not result[0] :
                    error_message = self.username + ' 为用户' + username + '新增主机时失败,提交保存时发生错误,原因:' + result[1]
                    self.logger.error(error_message) 
                    http_referer = self.uri_api.get_httpreferer(username, no=-1)
                    return render(request, 'result.html', {'error_message' : error_message, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
                else :
                    self.logger.info(self.username + ' 为用户' + username + '新增主机,提交保存成功')
                    return HttpResponseRedirect(reverse('inventory_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:26,代码来源:inventory.py

示例11: detail

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def detail(self, request):
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        vault_password = request.session['vault_password']
        name = request.GET.get('name')
        result = self.inventory_api.detail(username, vault_password, name)
        if result[0] :
            self.logger.info(self.username + ' 查看用户' + username + '的名为' + name + '的主机,查询成功')
            return render(request, 'inve_detail.html', {'name':name, 'detail_dict':result[1] , 'login_user':username, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            error_message = self.username + ' 查看用户' + username + '的名为' + name + '的主机,查询时发生错误,原因:' + result[1]
            self.logger.error(error_message) 
            return HttpResponseRedirect(reverse('inventory_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:19,代码来源:inventory.py

示例12: delete

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def delete(self, request):
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
        
        name = request.GET.get('name')
        result = self.inventory_api.delete(username, name)
        http_referer = self.uri_api.get_httpreferer(username, no=-1)
        if not result[0] :               
            error_message = self.username + ' 删除用户' + username + '的名为' + name + '的主机失败,提交保存时发生错误,原因:' + result[1]
            self.logger.error(error_message) 
            return render(request, 'result.html', {'name':name , 'login_user':username, 'http_referer':http_referer, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html})
        else :
            self.logger.info(self.username + ' 删除用户' + username + '的名为' + name + '的主机,提交保存成功')
            return HttpResponseRedirect(reverse('inventory_list')) 
开发者ID:lykops,项目名称:lykops,代码行数:19,代码来源:inventory.py

示例13: event_review

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def event_review(request, pk, token, slug=None, event_detail_template='events/event_detail.html'):
    # TODO: Add reference in email for analytics
    # TODO: Add history of reviews in review page
    event = get_object_or_404(models.Event, pk=pk)
    if event.slug != slug:
        return redirect(event.get_absolute_url())

    form = EventReviewForm(data=request.POST)
    if form.is_valid():
        review = services.create_event_review(request.user, event, form.cleaned_data)
        services.update_event_visibility(review)
        services.send_event_review_mail(review, request.user)
        return HttpResponseRedirect(reverse('home'))

    ctx = {
        'event': event,
        'review_url': services.get_event_review_url(event),
        'form': form
    }
    return render(request, event_detail_template, ctx) 
开发者ID:fossevents,项目名称:fossevents.in,代码行数:22,代码来源:views.py

示例14: test_post

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def test_post(self):
        requestObj = self.tempForm.__class__.__dict__['request']
        actionParam = (fClassesNames[1], groupName, '')

        for i in range(0, 6):
            setattr(requestObj, 'POST', {'action': actionParam[i % 3]})

            response = self.tempForm.post(requestObj)
            if isinstance(response, HttpResponseRedirect):
                self.assertEqual(response.url, self.tempForm.success_url)
            else:
                self.assertEqual(response.status_code, 200)

            if i == 2:
                global form_valid
                form_valid = True

        setattr(requestObj, 'POST', requestMethodNames[0]) 
开发者ID:iguana-project,项目名称:iguana,代码行数:20,代码来源:test_multiform.py

示例15: _process_grouped_forms

# 需要导入模块: from django.http import response [as 别名]
# 或者: from django.http.response import HttpResponseRedirect [as 别名]
def _process_grouped_forms(self, group_name, form_classes):
        """
        Perform the is_valid() check for a group of forms.
        """
        form_names = self.grouped_forms[group_name]
        forms = self.get_forms(form_classes, form_names)
        # check if all forms are valid
        if all([forms[formName].is_valid() for formName in forms if formName in form_names]):
            # process the group valid method
            self.forms_valid(forms, group_name, isGroup=True)

            # redirect to success url if at least one form was valid
            return HttpResponseRedirect(self.get_success_url())
        else:
            # process the group invalid method
            self.forms_invalid(forms, group_name, isGroup=True)

            # show errors instead
            return self.render_to_response(self.get_context_data(forms=forms)) 
开发者ID:iguana-project,项目名称:iguana,代码行数:21,代码来源:multiform.py


注:本文中的django.http.response.HttpResponseRedirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。