From 701f6f5c2e5329f6d48fa77efd1d7231ed1e31a8 Mon Sep 17 00:00:00 2001 From: mutr Date: Tue, 3 Dec 2019 16:40:11 +0300 Subject: [PATCH] Fix sorting error on self-referencing fields There is a chance that model will be sorted wrong if self-referencing model coexists with foreign models. --- statik/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statik/database.py b/statik/database.py index f68d8cf..af5c207 100644 --- a/statik/database.py +++ b/statik/database.py @@ -160,7 +160,7 @@ def sort_models(self): model = self.models[model_names[i]] # check if this model has any dependencies which haven't been taken care of in this round for foreign_model_name in model.foreign_models: - if foreign_model_name not in sorted_models: + if foreign_model_name not in sorted_models and foreign_model_name != model.name: sorted_models.append(foreign_model_name) if model.name not in sorted_models: