Преглед на файлове

[core] Backport Django #16317 Self-referencing model with natural key

Getting error: dumpdata can't resolve dependencies
https://code.djangoproject.com/ticket/16317
Romain Rigaux преди 11 години
родител
ревизия
74b5d72
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      desktop/core/ext-py/Django-1.4.5/django/core/management/commands/dumpdata.py

+ 2 - 2
desktop/core/ext-py/Django-1.4.5/django/core/management/commands/dumpdata.py

@@ -146,11 +146,11 @@ def sort_dependencies(app_list):
             for field in model._meta.fields:
                 if hasattr(field.rel, 'to'):
                     rel_model = field.rel.to
-                    if hasattr(rel_model, 'natural_key'):
+                    if hasattr(rel_model, 'natural_key') and rel_model != model:
                         deps.append(rel_model)
             for field in model._meta.many_to_many:
                 rel_model = field.rel.to
-                if hasattr(rel_model, 'natural_key'):
+                if hasattr(rel_model, 'natural_key') and rel_model != model:
                     deps.append(rel_model)
             model_dependencies.append((model, deps))