Is there a established way that i validate an object in the dispatch without making an extra database call when self.get_object()
is called later in get/post?
Here is what i have so far (slightly altered for this question):
class CourseUpdateView(UpdateView):def dispatch(self, request, *args, **kwargs):self.request = requestself.kwargs = kwargsself.object = self.get_object()if self.object.is_online:messages.warning(request, "Sorry this one can't be updated")return redirect("course:detail", pk=self.kwargs['pk'])# this is going to call self.get_object again isn't it?return UpdateView.dispatch(self, request, *args, **kwargs)