From af27a1bc4b82bc0fad06e882d7d02b6fad0282f0 Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Wed, 25 Nov 2020 16:11:27 +0100
Subject: [PATCH 1/4] declare on_delete behaviour on ForeignKey (#49062)

---
 django_journal/migrations/0001_initial.py | 10 +++++-----
 django_journal/models.py                  | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/django_journal/migrations/0001_initial.py b/django_journal/migrations/0001_initial.py
index cce8e31..8a5def2 100644
--- a/django_journal/migrations/0001_initial.py
+++ b/django_journal/migrations/0001_initial.py
@@ -30,8 +30,8 @@ class Migration(migrations.Migration):
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('object_id', models.PositiveIntegerField(verbose_name='object id', db_index=True)),
-                ('content_type', models.ForeignKey(verbose_name='content type', to='contenttypes.ContentType')),
-                ('journal', models.ForeignKey(verbose_name='journal entry', to='django_journal.Journal')),
+                ('content_type', models.ForeignKey(verbose_name='content type', to='contenttypes.ContentType', on_delete=models.CASCADE)),
+                ('journal', models.ForeignKey(verbose_name='journal entry', to='django_journal.Journal', on_delete=models.CASCADE)),
             ],
             options={
                 'verbose_name': 'linked object',
@@ -42,7 +42,7 @@ class Migration(migrations.Migration):
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('content', models.TextField(verbose_name='content')),
-                ('journal', models.ForeignKey(verbose_name='journal entry', to='django_journal.Journal')),
+                ('journal', models.ForeignKey(verbose_name='journal entry', to='django_journal.Journal', on_delete=models.CASCADE)),
             ],
             options={
                 'verbose_name': 'linked text string',
@@ -72,12 +72,12 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='stringdata',
             name='tag',
-            field=models.ForeignKey(verbose_name='tag', to='django_journal.Tag'),
+            field=models.ForeignKey(verbose_name='tag', to='django_journal.Tag', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='objectdata',
             name='tag',
-            field=models.ForeignKey(verbose_name='tag', to='django_journal.Tag'),
+            field=models.ForeignKey(verbose_name='tag', to='django_journal.Tag', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='journal',
diff --git a/django_journal/models.py b/django_journal/models.py
index c51abc2..10840bf 100644
--- a/django_journal/models.py
+++ b/django_journal/models.py
@@ -122,8 +122,8 @@ class StringData(models.Model):
        content:
            the string value of the data
     '''
-    journal = models.ForeignKey(Journal, verbose_name=_('journal entry'))
-    tag = models.ForeignKey(Tag, verbose_name=_('tag'))
+    journal = models.ForeignKey(Journal, verbose_name=_('journal entry'), on_delete=models.CASCADE)
+    tag = models.ForeignKey(Tag, verbose_name=_('tag'), on_delete=models.CASCADE)
     content = models.TextField(verbose_name=_('content'))
 
     class Meta:
@@ -142,9 +142,9 @@ class ObjectData(models.Model):
        content_object:
            the object value of the data
     '''
-    journal = models.ForeignKey(Journal, verbose_name=_('journal entry'))
-    tag = models.ForeignKey(Tag, verbose_name=_('tag'))
-    content_type = models.ForeignKey('contenttypes.ContentType',
+    journal = models.ForeignKey(Journal, verbose_name=_('journal entry'), on_delete=models.CASCADE)
+    tag = models.ForeignKey(Tag, verbose_name=_('tag'), on_delete=models.CASCADE)
+    content_type = models.ForeignKey('contenttypes.ContentType', on_delete=models.CASCADE,
             verbose_name=_('content type'))
     object_id = models.PositiveIntegerField(db_index=True,
             verbose_name=_('object id'))
-- 
2.20.1

