Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError if the file associated with a model instance has been removed, and delete() is called on a ModelForm for that instance. #76

Open
AbhigyaShridhar opened this issue May 2, 2022 · 1 comment

Comments

@AbhigyaShridhar
Copy link

AbhigyaShridhar commented May 2, 2022

Steps to reproduce:

  • Create a model, PrivateModel and set one field as PrivateFileField
  • Create another model, say TestModel and reference PrivateModel as a foreign key
  • Run migrations and set up django admin for TestModel keeping PrivateModel as inline
  • Create a test instance for both the models
  • Go to the PRIVATE_STORAGE_ROOT path and manually delete the file associated with newly created TestModel instance
  • Now delete that instance using django admin page (by marking the inline for deletion)

Expected outcome:
The PrivateModel instance marked for deletion is removed and TestModel instance is updated successfully

Actual Outcome:
Throws FileNotFoundError

@AbhigyaShridhar
Copy link
Author

Note that the error doesn't occur when delete() is called on the model instance itself, it only occurs when delete() is called from a ModelForm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant