在基于DeleteView的类中,成功的URL不起作用可能是由于以下几个原因:
from django.views.generic import DeleteView
class MyDeleteView(DeleteView):
model = MyModel
success_url = '/success-url/'
from django.urls import reverse_lazy
from django.views.generic import DeleteView
class MyDeleteView(DeleteView):
model = MyModel
success_url = reverse_lazy('success-url-name')
from django.urls import reverse_lazy
from django.views.generic import DeleteView
class MyDeleteView(DeleteView):
model = MyModel
success_url = reverse_lazy('success-url-name')
def delete(self, request, *args, **kwargs):
# 执行删除操作
self.object = self.get_object()
self.object.delete()
return HttpResponseRedirect(self.get_success_url())
请注意,以上答案中没有提及具体的腾讯云产品和产品介绍链接地址,因为要求答案中不能提及亚马逊AWS、Azure、阿里云、华为云、天翼云、GoDaddy、Namecheap、Google等流行的一些云计算品牌商。如果需要了解腾讯云相关产品和产品介绍,请参考腾讯云官方文档或咨询腾讯云官方客服。
领取专属 10元无门槛券
手把手带您无忧上云