You have a dictionary, use `dict.get()` to return a default value for missing keys: image_file = self.request.files.get('image_path')