Skip to content

Commit

Permalink
BookInstance.book needs default value (#89)
Browse files Browse the repository at this point in the history
* Add default null value for BookInstance.book

* Add migration for default BookInstance.book value
  • Loading branch information
hamishwillee committed Mar 2, 2021
1 parent 02132ec commit ffd903b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions catalog/migrations/0024_auto_20210302_0630.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.1.2 on 2021-03-02 06:30

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('catalog', '0023_auto_20201201_0238'),
]

operations = [
migrations.AlterField(
model_name='bookinstance',
name='book',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.RESTRICT, to='catalog.book'),
),
]
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.RESTRICT)
book = models.ForeignKey('Book', on_delete=models.RESTRICT, null=True)
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 ffd903b

Please sign in to comment.