On Sunday 07 May 2017 16:10:27 Nonverbis M wrote: > class FileUpdate(UpdateView): > model = UserFile > form_class = FileForm > > def form_valid(self, form): > """ > Delete old file. > """ > parent_directory = get_parent_directory_of_file(self.object) > old_file_name = self.object.user_file.name # Breakpoint > self.object.user_file.delete() > return super(FileUpdate, self).form_valid(form)
I've battled with this too and by far the simplest way to solve it, is to put the old file name in the form as a hidden widget. -- Melvyn Sopacua -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/23778917.yV3JeFkZZR%40devstation. For more options, visit https://groups.google.com/d/optout.