[Fixed]-How to tell if user changed file in django ModelForm

1đź‘Ť

âś…

In general, you can do this with self.changed_data, which returns a list of the names of the fields where the value changed. Whether there’s anything special about a FileField that would interfere I don’t know offhand.

0đź‘Ť

In js,

  • In JS, set a global variable file_changed = 0.
  • HTML input tag < input ng-model=”avatar” type=”file” onchange=”ChangeFile()”>
  • Lets say ChangeFile() will provide a small preview of the file to be uploaded
  • In function ChangeFile set file_changed=1 once the file is selected.
👤SuperNova

Leave a comment