Specify the on_delete strategy

- Remove an absurd debug line in the migration
- Specify the on_delete strategy for the club-related models
This commit is contained in:
Martin Pépin 2017-02-23 10:47:48 +01:00
parent f8a8465630
commit 7d1c1fc868
2 changed files with 8 additions and 5 deletions

View file

@ -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(

View file

@ -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"))