How to make model with list of different data type

I'm really new to django, especially SQL, I usually use NO SQL as a database, I want to know how to create a model like this?

{
    "title" : "Smarthome by me",
    "description" : "A Hello World App",
    "publishedAt" : "2024-02-18 20:14:34.208116",
    "modifiedAt" : "2024-02-18 20:14:34.208116",
    "contents" : [ 
        {
            "type" : "ImageBased",
            "name" : "im1 it's a lake with two mountain",
            "content" : "img.png" #Store some Image field
        },
        {
            "type" : "TextBased",
            "name" : None,
            "content" : "" #Store some Text field
        },
        {
            "type" : "URLTextBased",
            "name" : None,
            "content" : "https://www.youtube.com/watch?v=AswXiy8JCsI&t=1808s" #Store some Text field
        },
        {
            "type" : "VideoBased",
            "name" : None,
            "content" : "video.mp4" #Store some File field
        },
    ]
}

Main needs:

  • The order of content must match what is posted
  • publishedAt cannot be modified modifiedAt must be updated every time there is an update
Back to Top