*Django 1.11*
When FileUpdate is called, I substitute the old file with a new one. I'd like to handle the old file. Namely move it to some other directory. Could you have a look at the picture below. New file is called "C book 1.pdf". Existing file is called "4_Oracle_Database_11g_PLSQL_Fundamentals_PLSQL.pdf". <https://lh3.googleusercontent.com/-ypH3wS4KQVM/WQ-pNd2VtgI/AAAAAAAAA5s/FD3AVgsbOHsUhZtSJngR6GcYoncYiN4-QCLcB/s1600/Screenshot%2Bfrom%2B2017-05-07%2B22-46-00.png> But at the breakpoint (see comment in form_valid), old_file_name = C book 1.pdf. But I can't catch why. I call super(FileUpdate, self).form_valid(form) in a couple of lines. And only there self.object = form.save(). At the breakpoint I expect self.object to be the unchanged object. Existing one. *Could you help me understand how to catch the file name of the old file.* class UserFile(models.Model): uuid = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False) user_file = models.FileField(verbose_name=_("file"), max_length=255, upload_to=get_file_path) 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) -- 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 [email protected]. To post to this group, send email to [email protected]. 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/36d54c66-270b-4ca5-beda-76c7f9865caf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

