Virtual Tables and Django Foreignkeys
I have been continuing with my virtual table implementation, though taking a short break to do some more integration on the Django side.
I have an ideas site that I use as a kind of wiki to keep track of various ideas.
# the default model I'm using from my virtual table integration
class FrontmatterModel(models.Model):
inode = models.PositiveIntegerField(primary_key=True, editable=False)
path = models.FilePathField(unique=True, editable=False)
slug = models.SlugField()
content = models.TextField()
excerpt = models.TextField(blank=True)
metadata = models.JSONField()
class Meta:
abstract = True
# Custom model for my idea object itself
# These also exist in the `metadata` json frontmatter, but putting them here
# makes them nicer to deal with from Django
class Idea(FrontmatterModel):
title = models.CharField(max_length=128)
status = models.ForeignKey(Status, on_delete=models.SET_NULL, null=True, db_column="dir")
homepage = models.URLField(blank=True)
repository = models.URLField(blank=True)
focus = models.BooleanField(default=False)
date = models.DateTimeField(default=timezone.now)
class Meta:
required_db_vendor = "markdowndb"
managed = False
The model ultimately gets sent to the virtual table backend with a statement that looks like this
Read More →