def get_context_data(self, **kwargs): context = super(CreateOrUpdateView, self).get_context_data(**kwargs) context["is_new"] = (not self.object.pk) context["front_url"] = get_model_front_url(self.request, self.object) context["title"] = get_create_or_change_title(self.request, self.object) context["save_form_id"] = self.get_save_form_id() context["toolbar"] = self.get_toolbar() context["iframe_mode"] = bool( self.request.GET.get("mode", "") == "iframe") if context[ "iframe_mode"] and self.object and self.object.id is not None: name = None for field in get_possible_name_fields_for_model( self.object.__class__): name = getattr(self.object, field, None) if name: break context["iframe_close"] = bool( self.request.GET.get("iframe_close")) context["quick_add_target"] = self.request.GET.get( "quick_add_target", "") context["quick_add_callback"] = self.request.GET.get( "quick_add_callback", "") context["quick_add_option_id"] = self.object.id context["quick_add_option_name"] = name if name else _("Unnamed") return context
def get_context_data(self, **kwargs): context = super(CreateOrUpdateView, self).get_context_data(**kwargs) context["is_new"] = (not self.object.pk) context["front_url"] = get_model_front_url(self.request, self.object) context["title"] = get_create_or_change_title(self.request, self.object) context["save_form_id"] = self.get_save_form_id() context["toolbar"] = self.get_toolbar() context["iframe_mode"] = bool(self.request.GET.get("mode", "") == "iframe") if context["iframe_mode"] and self.object and self.object.id is not None: name = None for field in get_possible_name_fields_for_model(self.object.__class__): name = getattr(self.object, field) if name: break context["iframe_close"] = bool(self.request.GET.get("iframe_close")) context["quick_add_target"] = self.request.GET.get("quick_add_target", "") context["quick_add_option_id"] = self.object.id context["quick_add_option_name"] = name if name else _("Unnamed") return context