Editing a book results in apparent error despite the edit succeeding
After editing a book, the user is returned to the edit page, but a message is displayed "The book already exists in the server." This is confusing because it implies the edit was not possible, but the edit in fact was successful.
Repro
- Login
- View book detail
- Click "edit"
- Change the book title field
- Click "edit" to submit
Expected User is redirected to the book detail page.
Actual Error "The book already exists in the server." appears.

I've looking for this issue and I've found that validate_unique doesn't check if sha256 refers to current object or not.
I've made a small fix but there are others issues later in forms.py...
def validate_unique(self, *args, **kwargs):
if not self.file_sha256sum:
self.file_sha256sum = sha256_sum(self.book_file)
- if (self.__class__.objects.filter(
- file_sha256sum=self.file_sha256sum).exists()):
+ unicity = self.__class__.objects.filter(file_sha256sum=self.file_sha256sum)
+ if self.pk is not None:
+ unicity = unicity.exclude(pk=self.pk)
+ if (unicity.exists()):
raise ValidationError({
NON_FIELD_ERRORS:['The book already exists in the server.',]})
This fix requires testing but I saw that you have began upgrading this project to Django 1.11, I'll be happy to help with adding test.