| 602 | return context |
| 603 | |
| 604 | def value_from_datadict(self, data, files, name): |
| 605 | upload = super().value_from_datadict(data, files, name) |
| 606 | self.checked = self.clear_checkbox_name(name) in data |
| 607 | if not self.is_required and CheckboxInput().value_from_datadict( |
| 608 | data, files, self.clear_checkbox_name(name) |
| 609 | ): |
| 610 | if upload: |
| 611 | # If the user contradicts themselves (uploads a new file AND |
| 612 | # checks the "clear" checkbox), we return a unique marker |
| 613 | # object that FileField will turn into a ValidationError. |
| 614 | return FILE_INPUT_CONTRADICTION |
| 615 | # False signals to clear any existing value, as opposed to just |
| 616 | # None |
| 617 | return False |
| 618 | return upload |
| 619 | |
| 620 | def value_omitted_from_data(self, data, files, name): |
| 621 | return ( |