Fix slug for data file
This commit is contained in:
parent
67dfd04bbb
commit
58fda689bf
3 changed files with 6 additions and 2 deletions
|
@ -1,2 +1,4 @@
|
|||
- title: Foo
|
||||
content: bar
|
||||
- title: Bar
|
||||
content: foo
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue