0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 09:33:54 +01:00

Add on_delete= on search models

This commit is contained in:
Karl Hobley 2017-10-26 16:02:36 +01:00 committed by Matt Westcott
parent bf7936ade2
commit be6284c0a0
2 changed files with 3 additions and 3 deletions

View File

@ -48,7 +48,7 @@ class Migration(migrations.Migration):
fields=[
('book_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='searchtests.Book')),
('setting', models.CharField(max_length=255)),
('protagonist', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='searchtests.Character')),
('protagonist', models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='searchtests.Character')),
],
bases=('searchtests.book',),
),

View File

@ -71,7 +71,7 @@ class Book(index.Indexed, models.Model):
class Character(models.Model):
name = models.CharField(max_length=255)
novel = models.ForeignKey('Novel', related_name='characters')
novel = models.ForeignKey('Novel', related_name='characters', on_delete=models.CASCADE)
search_fields = [
index.SearchField('name'),
@ -83,7 +83,7 @@ class Character(models.Model):
class Novel(Book):
setting = models.CharField(max_length=255)
protagonist = models.OneToOneField(Character, related_name='+', null=True)
protagonist = models.OneToOneField(Character, related_name='+', null=True, on_delete=models.SET_NULL)
search_fields = Book.search_fields + [
index.SearchField('setting', partial_match=True),