mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
fix: Utilisation du signal "post-migrate" pour créer la spécialité par
défaut
This commit is contained in:
@ -1,11 +1,14 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.db.models.signals import post_migrate
|
||||||
|
|
||||||
|
def create_specialite(sender, **kwargs):
|
||||||
|
from .models import Specialite
|
||||||
|
if not Specialite.objects.filter(nom='TRANSVERSE').exists():
|
||||||
|
Specialite.objects.create(nom='TRANSVERSE', codeCouleur='#FF0000')
|
||||||
|
|
||||||
class GestionenseignantsConfig(AppConfig):
|
class GestionenseignantsConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'GestionEnseignants'
|
name = 'GestionEnseignants'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from .models import Specialite
|
post_migrate.connect(create_specialite, sender=self)
|
||||||
if not Specialite.objects.filter(nom='TRANSVERSE').exists():
|
|
||||||
Specialite.objects.create(nom='TRANSVERSE', codeCouleur='#FF0000')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user