How can I add a model watchlist, so that it has four categories/lists/sections, namely: currently-watching, on-hold, plan-to-watch, completed? Each movie can only be in one category at a time.

My expectation is something like this:-

class watchlist(models.Model):
    currently_watching = all_movies_in_currently_watching
    on_hold = all_movies_in_on_hold
    planning_to_watch = all_movies_in_planning_to_watch
    completed = all_movies_in_completed

from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
from django.contrib.auth.models import User

# Create your models here.

class Tag(models.Model):
    name = models.CharField(max_length=55)

    def __str__(self):

class Movie(models.Model):
    title = models.CharField(max_length=255)
    release_year = models.PositiveIntegerField(validators=[
    duration_in_min = models.PositiveSmallIntegerField()
    imdb_rating = models.DecimalField(max_digits=2, decimal_places=1)
    rotten_tomatoes_score = models.PositiveSmallIntegerField(validators=[
    cover_img = models.ImageField(upload_to="cover_images")
    tags = models.ManyToManyField(Tag)

    def __str__(self):
        return self.title

I would set this up with a Watchlist like this:

class Watchlist(Model):
    list_name = CharField(...)

This model would have 4 entries, one for each category.

Then, your Movie model would have a foreign key to Watchlist, the entry identifying which list it was in.


I think you can make your class WatchList(models.Model):
As follows in one of the two ways (I preferred the second way):

class WatchList(models.Model):
        ("", "Choose One Of The Following Plan"),
        ("current", "Currently Watching"),
        ("hold", "On Hold"),
        ("plan", "Plan To Watch"),
        ("completed", "Completed"),
    category = models.CharField(max_length=15, choices=MY_LIST)

You can use it in your views as

current_watching = WatchList.objects.filter(category="current")

The second way is :

        (0, "Choose One Of The Following Plan"),
        (1, "Currently Watching"),
        (2, "On Hold"),
        (3, "Plan To Watch"),
        (4, "Completed"),
    currently_watching =  models.IntegerField(

you can use it in views as follows:

current_watching = WatchList.objects.filter(category=1)
on_hold = WatchList.objects.filter(category=2)
plan_to_watch = WatchList.objects.filter(category=3)
completed = WatchList.objects.filter(category=4)

and you must take in your consideration what Ken said about the ForeignKey
Hope it helps

1 Like