From 9f2e49c9e9c30d42887b68242980046f3851746a Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 11 Sep 2019 14:46:39 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E4=B8=80=E4=BA=9B=E8=8A=82=E7=82=B9=E6=97=B6=EF=BC=8C?= =?UTF-8?q?assets=5Fnode=E8=A1=A8=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/apps.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/assets/apps.py b/apps/assets/apps.py index e210a1708..a7267c7b6 100644 --- a/apps/assets/apps.py +++ b/apps/assets/apps.py @@ -1,6 +1,16 @@ from __future__ import unicode_literals from django.apps import AppConfig +from django.db.models.signals import post_migrate + + +def initial_some_nodes(): + from .models import Node + Node.initial_some_nodes() + + +def initial_some_nodes_callback(sender, **kwargs): + initial_some_nodes() class AssetsConfig(AppConfig): @@ -9,5 +19,7 @@ class AssetsConfig(AppConfig): def ready(self): super().ready() from . import signals_handler - from .models import Node - Node.initial_some_nodes() + try: + initial_some_nodes() + except Exception: + post_migrate.connect(initial_some_nodes_callback, sender=self)