diff --git a/content/core.page/test2.md b/content/core.page/test2.md index 3ba7a60..f408913 100644 --- a/content/core.page/test2.md +++ b/content/core.page/test2.md @@ -1,5 +1,7 @@ --- title: Test +tags: + - tag-1 --- # Heading diff --git a/content/core.tag/tags.yml b/content/core.tag/tags.yml new file mode 100644 index 0000000..a88c53d --- /dev/null +++ b/content/core.tag/tags.yml @@ -0,0 +1,2 @@ +- slug: tag-1 +- slug: tag-2 diff --git a/requirements.txt b/requirements.txt index d9fbf0c..1d2435d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ django -git+https://github.com/andrewgodwin/yamdl +git+https://github.com/andrewgodwin/yamdl@8d34d7397f3564a550042e81ea79cca7d2f3777e gunicorn markdown diff --git a/yamdl_playground/core/models.py b/yamdl_playground/core/models.py index 3d0314d..1c951e4 100644 --- a/yamdl_playground/core/models.py +++ b/yamdl_playground/core/models.py @@ -1,9 +1,29 @@ from django.db import models +class Tag(models.Model): + __yamdl__ = True + + slug = models.SlugField(max_length=128, primary_key=True) + + content = models.TextField() + + class Page(models.Model): __yamdl__ = True title = models.CharField(max_length=255) - slug = models.CharField(max_length=128, unique=True, db_index=True, default=None, null=True) content = models.TextField() + slug = models.CharField(max_length=128, unique=True, db_index=True, default=None, null=True) + + tags = models.ManyToManyField(Tag) + + @classmethod + def from_yaml(cls, **data): + tags = data.pop("tags", None) + instance = cls.objects.create(**data) + + if tags: + instance.tags.set(tags) + + return instance