親ビューと子ビューがあります。次のように、子ビューで1つのカスタム関数をオーバーライドしたい:
私の URL:
path('<int:place_id>/add_images/', AddImages.as_view(), name="add-images"),
path('<int:place_id>/edit/images/', EditImages.as_view(), name="edit-images"),
# PARENT:
class AddImages(LoginRequiredMixin, View):
template_name = images/add_images.html
# HERE I GET THE CURRENT URL:
def next_url(self):
next_url = "?next={0}".format(self.request.path)
print("NEXT URL:" + str(next_url))
return next_url
# AND I USE IT HERE:
def post(self, request, **kwargs):
# ...
next_url = self.next_url()
data = {'next_url' : next_url }
return JsonResponse(data)
# CHILD:
class EditImages(AddImages):
"""
Inherits from ImagesView. overwrites template and next_url
"""
template_name = "images/edit_images.html"
def next_url(self):
next_url = "?next={0}".format(self.request.path)
print("CHILD URL2:" + str(next_url))
return next_url
親ビューの next_url をオーバーライドして、post() に渡したい
現在、出力は次のように表示されます: "NEXT URL: ..."
どうすればこれを解決できますか? 前もって感謝します