Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将以下 django 视图用于许多不同的视图,有没有办法重定向到调用它的视图?
def delete_image(request,id,image_id): ImagenAvaluo.objects.filter(image_id=image_id).delete() return calling_view(request,id)
创建一个单独的函数并在多个视图中使用它:
def delete_images(image_id): ImagenAvaluo.objects.filter(image_id=image_id).delete()
这样您就不必跟踪哪个视图调用了哪个其他视图。它还可以避免您传递request对象。
request