Protect foreign keys
This commit is contained in:
parent
a562f7587a
commit
4499ee8c6b
2 changed files with 44 additions and 5 deletions
39
manuels/migrations/0008_auto_20180522_1051.py
Normal file
39
manuels/migrations/0008_auto_20180522_1051.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Generated by Django 2.0.5 on 2018-05-22 08:51
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('manuels', '0007_auto_20180522_1026'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='book',
|
||||
name='editor',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='manuels.Editor', verbose_name='éditeur'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='book',
|
||||
name='level',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='manuels.Level', verbose_name='classe'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='book',
|
||||
name='teacher',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='manuels.Teacher', verbose_name='enseignant'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='suppliesrequirement',
|
||||
name='level',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='manuels.Level', verbose_name='classe'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='suppliesrequirement',
|
||||
name='teacher',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='manuels.Teacher', verbose_name='enseignant'),
|
||||
),
|
||||
]
|
|
@ -93,12 +93,12 @@ class Book(BaseModel):
|
|||
verbose_name = 'livre'
|
||||
verbose_name_plural = 'livres'
|
||||
|
||||
teacher = models.ForeignKey(verbose_name='enseignant', to=Teacher, on_delete=models.SET_NULL, null=True)
|
||||
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.SET_NULL, null=True)
|
||||
teacher = models.ForeignKey(verbose_name='enseignant', to=Teacher, on_delete=models.PROTECT, null=True)
|
||||
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True)
|
||||
field = models.CharField('matière', max_length=100)
|
||||
title = models.TextField('titre')
|
||||
authors = models.TextField('auteurs')
|
||||
editor = models.ForeignKey(verbose_name='éditeur', to=Editor, on_delete=models.SET_NULL, null=True)
|
||||
editor = models.ForeignKey(verbose_name='éditeur', to=Editor, on_delete=models.PROTECT, null=True)
|
||||
collection = models.CharField('collection', max_length=200, blank=True)
|
||||
publication_year = models.PositiveIntegerField('année de publication')
|
||||
isbn = models.CharField('ISBN/EAN', max_length=20, validators=[isbn_validator])
|
||||
|
@ -130,8 +130,8 @@ class SuppliesRequirement(BaseModel):
|
|||
verbose_name = 'demande de fournitures'
|
||||
verbose_name_plural = 'demandes de fournitures'
|
||||
|
||||
teacher = models.ForeignKey(verbose_name='enseignant', to=Teacher, on_delete=models.SET_NULL, null=True)
|
||||
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.SET_NULL, null=True)
|
||||
teacher = models.ForeignKey(verbose_name='enseignant', to=Teacher, on_delete=models.PROTECT, null=True)
|
||||
level = models.ForeignKey(verbose_name='classe', to=Level, on_delete=models.PROTECT, null=True)
|
||||
supplies = models.TextField('fournitures')
|
||||
|
||||
def __str__(self):
|
||||
|
|
Loading…
Reference in a new issue