[Fixed]-Django โ€“ Model with lists in a CharField

1๐Ÿ‘

โœ…

I think the easiest and the most obvious solution would be to to create two separate models โ€“ one for tasks list and another for a single task.

class TodoList(models.Model):
    # you can put here some additional information, like the name of the list, when it was created etc.

class Task(models.Model):
    todo_list = models.ForeignKey(TodoList)
    # you can put extra info about the single task (the creator, date due etc.)

So everytime you want to add a new task to your list, you create another Task object with todo_list fieldโ€™s value set to TodoList object.

Or you can add it another way, using reverse relationship as described in docs

๐Ÿ‘คmateuszb

Leave a comment