Skip to content

Commit

Permalink
Prevent book being deleted until all its instances are deleted (mdn#86)
Browse files Browse the repository at this point in the history
* Cascade book deletion

* Restrict deletion of book
  • Loading branch information
hamishwillee committed Dec 29, 2020
1 parent 33a0465 commit 02132ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class BookInstance(models.Model):
"""Model representing a specific copy of a book (i.e. that can be borrowed from the library)."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
help_text="Unique ID for this particular book across whole library")
book = models.ForeignKey('Book', on_delete=models.SET_NULL, null=True)
book = models.ForeignKey('Book', on_delete=models.RESTRICT)
imprint = models.CharField(max_length=200)
due_back = models.DateField(null=True, blank=True)
borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
Expand Down

0 comments on commit 02132ec

Please sign in to comment.