[Python] how to update / replace a file in a Django FileField()

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Django model that holds a file like so:

    class Excel(models.Model):
    the_generated_file = models.FileField()


    I know want to access this file with an updated version of the file. If this was a int, foat or Json field etc I could use something like:

    File_to_update = Excel.objects.all()
    File_to_update.update(the_generated_file = my_new_excel_previously_defined)


    But for some reason as it is of type FiledField() there is no update operation. How can I replace the old file with a new file?

    Continue reading...

Compartilhe esta Página