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
No comments:
Post a Comment