Following this article on polymorphism, I decied to use the semi-structured-model for my blog posts. The reason is that I just don’t know what kind of blog post types we are gonna need in the future. I want all the blog post to be of the same model type to keep sorting, displaying, etc… simple. However, I want the articles to have different structures. So there will be a simple post with no headline, a post containing of headline and textbody and there will be posts that also have media files attached.
In the django admin the json field should not be displayed. I don’t want users to have to write posts as JSON code. Instead I want a mask for each type of blog post. I found a useful package for that. Here is an example of the package in use to display a json field.
- If you have any suggestions or criticism for my design choices, please let me know.