diff --git a/content/core.page/test.yaml b/content/core.page/test.yaml index 90260bb..c7952a9 100644 --- a/content/core.page/test.yaml +++ b/content/core.page/test.yaml @@ -1,2 +1,4 @@ - title: Foo content: bar +- title: Bar + content: foo diff --git a/yamdl_playground/core/models.py b/yamdl_playground/core/models.py index 80807c1..3d0314d 100644 --- a/yamdl_playground/core/models.py +++ b/yamdl_playground/core/models.py @@ -4,6 +4,6 @@ class Page(models.Model): __yamdl__ = True title = models.CharField(max_length=255) - slug = models.CharField(max_length=128, unique=True, db_index=True) + slug = models.CharField(max_length=128, unique=True, db_index=True, default=None, null=True) content = models.TextField() diff --git a/yamdl_playground/core/utils.py b/yamdl_playground/core/utils.py index 9c8399d..7395799 100644 --- a/yamdl_playground/core/utils.py +++ b/yamdl_playground/core/utils.py @@ -2,5 +2,7 @@ from yamdl.loader import ModelLoader class CustomYamdlLoader(ModelLoader): def load_fixture(self, model_class, data, file_path): - data["slug"] = file_path.stem + if file_path.suffix not in self.EXT_YAML: + data["slug"] = file_path.stem + super().load_fixture(model_class, data, file_path)