mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #16317 -- Fixed dumpdata for self-referencing models and natural keys
Thanks aldaran for the patch.
This commit is contained in:
@@ -150,11 +150,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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user