1👍
You’re worrying unnecessarily about storing a (presumably) small amount of text along with your ToDoList
. Here’s how I would handle it, if the goal was to keep it simple, and not add another model.
class ToDoList(models.Model):
name = models.CharField(...)
validated_at = models.DateTimeField(..., null=True, editable=False)
rejection_reason = models.TextFiel(..., editable=False)
Query for validated_at__isnull=False
to get validated todo lists, ignoring rejection_reason
altogether. Query for validated_at__isnull=True
to get a list of unvalidated todo lists, and use rejection_reason
to display the reason to the user. If you want to save space in your database, empty the rejection_reason
field when a todo list is validated. You can also use filter (rejection_reason="")
to narrow the todo lists to those that don’t have a rejection reason (e.g., those that haven’t been validated or rejected yet), or exclude
on the same thing to get those that have been rejected.