From 5b2207bd59915e60768b250ffd6da7d123082a20 Mon Sep 17 00:00:00 2001 From: Qwann Date: Wed, 8 Aug 2018 16:56:24 +0200 Subject: [PATCH] cascade or protect set --- .../migrations/0008_auto_20180808_1454.py | 21 +++++++++++++++++++ equipment/models.py | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 equipment/migrations/0008_auto_20180808_1454.py diff --git a/equipment/migrations/0008_auto_20180808_1454.py b/equipment/migrations/0008_auto_20180808_1454.py new file mode 100644 index 0000000..bc1127c --- /dev/null +++ b/equipment/migrations/0008_auto_20180808_1454.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.11 on 2018-08-08 14:54 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('equipment', '0007_equipmentattribute_equipmentattributevalue'), + ] + + operations = [ + migrations.AlterField( + model_name='equipment', + name='category', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='equipment.EquipmentCategory'), + ), + ] diff --git a/equipment/models.py b/equipment/models.py index 232ab01..9e55841 100644 --- a/equipment/models.py +++ b/equipment/models.py @@ -50,6 +50,7 @@ class Equipment(EventSpecificMixin, models.Model): ) category = models.ForeignKey( EquipmentCategory, + on_delete=models.PROTECT, ) class Meta: @@ -77,6 +78,7 @@ class EquipmentAttribute(models.Model): class EquipmentAttributeValue(models.Model): equipment = models.ForeignKey( Equipment, + on_delete=models.CASCADE, related_name="attributes", help_text=_("Matériel concerné par le defaut"), ) @@ -124,6 +126,7 @@ class EquipmentDefault(models.Model): remark = models.TextField(_("remarque sur le défaut")) equipment = models.ForeignKey( Equipment, + on_delete=models.CASCADE, related_name="remarks", help_text=_("Matériel concerné par le defaut"), ) @@ -147,6 +150,7 @@ class EquipmentLost(models.Model): ) equipment = models.ForeignKey( Equipment, + on_delete=models.CASCADE, related_name="losts", help_text=_("Matériel concerné par la perte"), ) @@ -160,6 +164,7 @@ class EquipmentRevision(models.Model): ) equipment = models.ForeignKey( Equipment, + on_delete=models.CASCADE, related_name="revisions", help_text=_("Matériel concerné par les révisions"), )