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


Python DeleteView.delete方法代码示例

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


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

示例1: delete

# 需要导入模块: from django.views.generic.edit import DeleteView [as 别名]
# 或者: from django.views.generic.edit.DeleteView import delete [as 别名]
    def delete(self, request, *args, **kwargs):
        relacion = self.get_object()
        (validez, mensaje) = self.valid_eliminar_rel(relacion)
        if validez:
            messages.success(request, mensaje)

            return DeleteView.delete(self, request, *args, **kwargs)

        else:
            messages.error(request, "ERROR : " + mensaje)
            return redirect(self.get_success_url())

        return DeleteView.delete(self, request, *args, **kwargs)
开发者ID:nelsondspy,项目名称:projectmn,代码行数:15,代码来源:view_itemrelacion.py

示例2: delete

# 需要导入模块: from django.views.generic.edit import DeleteView [as 别名]
# 或者: from django.views.generic.edit.DeleteView import delete [as 别名]
    def delete(self, request, *args, **kwargs):
        application = Application.objects.get(person = self.request.user, id = self.kwargs['pk'])

        # We do not want the user to delete an application already approved
        # this will mess up with class counts and expectations
        if not application.approved:
            # Delete application permit file associated with this application
            try:
                applicationpermit = ApplicationPermit.objects.get(application = application)

                if logger.isEnabledFor(logging.DEBUG):
                    logger.debug("İzin yazısı silindi: %s , request.user='%s' , request.META['REMOTE_ADDR']='%s'" %
                                 (applicationpermit, request.user, request.META["REMOTE_ADDR"]))

                applicationpermit.delete()
                messages.info(request, _('Your previously uploaded permit is deleted'))
            except ApplicationPermit.DoesNotExist:
                pass

            messages.info(request, _('Your application is deleted'))
            messages.info(request, _('Your previous choices for this event are deleted'))

            if logger.isEnabledFor(logging.DEBUG):
                logger.debug("Başvuru silindi: %s , request.user='%s' , request.META['REMOTE_ADDR']='%s'" %
                             (application, request.user, request.META["REMOTE_ADDR"]))

            return DeleteView.delete(self, request, *args, **kwargs)

        else:
            messages.error(request, _('You are not allowed to cancel an application after it is approved'))
            return render_to_response('kurs/hata.html',
                        context_instance=RequestContext(request))
开发者ID:ebayer,项目名称:lkd-kurs,代码行数:34,代码来源:views.py


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