def form_valid_formset(self, form: ModelForm, formset: ProfileFormSet) -> HttpResponseRedirect: if formset.is_valid(): formset.save(commit=False) formset.save() else: return HttpResponseRedirect(self.get_success_url()) form.save() return HttpResponseRedirect(self.get_success_url())
def save_existing(self, form: ModelForm, instance: Page, commit: bool = True) -> Page: """Replace an existing chapter page.""" with form.instance.image.open('rb') as img: dgst = blake2b(img.read(), digest_size=16) ext = form.instance.image.name.split(".")[-1] path = form.instance.chapter.get_directory() name = str(path / f'{dgst.hexdigest()}.{ext}') form.instance.image.name = name return form.save(commit=commit)
def save(self, commit=True): instance = ModelForm.save(self, commit=False) return UrlShortener.objects.get_or_create_short( url_long=instance.url_long, automatico=False, link_absoluto=True)
def save(self, user, commit=True): self.instance.user = user return ModelForm.save(self, commit=commit)
def save(self): return ModelForm.save(self)
def save(self, commit=True): inst = ModelForm.save(self, commit=True) return inst