本文整理汇总了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)
示例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))