From 7d1c1fc868ac5ffdb283023b73b4b81ca32d0e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 23 Feb 2017 10:47:48 +0100 Subject: [PATCH] Specify the on_delete strategy - Remove an absurd debug line in the migration - Specify the on_delete strategy for the club-related models --- gestion/migrations/0002_club_support.py | 9 ++++++--- gestion/models.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gestion/migrations/0002_club_support.py b/gestion/migrations/0002_club_support.py index 6b23882b..dc16f400 100644 --- a/gestion/migrations/0002_club_support.py +++ b/gestion/migrations/0002_club_support.py @@ -64,7 +64,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(lambda: 1/0), migrations.CreateModel( name='Club', fields=[ @@ -82,8 +81,12 @@ class Migration(migrations.Migration): ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), ('is_respo', models.BooleanField(verbose_name='Est responsable du club')), ('has_paid', models.BooleanField(verbose_name='A payƩ sa cotisation')), - ('club', models.ForeignKey(to='gestion.Club')), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ('club', models.ForeignKey( + to='gestion.Club', + on_delete=models.CASCADE)), + ('user', models.ForeignKey( + on_delete=models.CASCADE, + to=settings.AUTH_USER_MODEL)), ], ), migrations.AddField( diff --git a/gestion/models.py b/gestion/models.py index 98c06d0e..5716cb1b 100644 --- a/gestion/models.py +++ b/gestion/models.py @@ -96,7 +96,7 @@ class Club(models.Model): class ClubUser(models.Model): - user = models.ForeignKey(User) - club = models.ForeignKey(Club) + user = models.ForeignKey(User, on_delete=models.CASCADE) + club = models.ForeignKey(Club, on_delete=models.CASCADE) is_respo = models.BooleanField(_("Est responsable du club")) has_paid = models.BooleanField(_("A payƩ sa cotisation"))