Set null on user delete.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 9 Jun 2021 09:59:24 +0000 (11:59 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 9 Jun 2021 09:59:24 +0000 (11:59 +0200)
src/club/migrations/0027_auto_20210609_1158.py [new file with mode: 0644]
src/club/models.py

diff --git a/src/club/migrations/0027_auto_20210609_1158.py b/src/club/migrations/0027_auto_20210609_1158.py
new file mode 100644 (file)
index 0000000..fa0edb8
--- /dev/null
@@ -0,0 +1,19 @@
+# Generated by Django 2.2.19 on 2021-06-09 09:58
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('club', '0026_schedule_source'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='schedule',
+            name='membership',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='club.Membership', verbose_name='membership'),
+        ),
+    ]
index babe6f5..a8b07ab 100644 (file)
@@ -47,7 +47,7 @@ class Schedule(models.Model):
     """ Represents someone taking up a plan. """
     key = models.CharField(_('key'), max_length=255, unique=True)
     email = models.EmailField(_('email'))
-    membership = models.ForeignKey('Membership', verbose_name=_('membership'), null=True, blank=True, on_delete=models.PROTECT)
+    membership = models.ForeignKey('Membership', verbose_name=_('membership'), null=True, blank=True, on_delete=models.SET_NULL)
     amount = models.DecimalField(_('amount'), max_digits=10, decimal_places=2)
     monthly = models.BooleanField(_('monthly'), default=True)
     yearly = models.BooleanField(_('yearly'), default=False)