I want the form to update in real-time

I want the form to update in real-time: when subjects are selected in subject_id, the demo_video dropdown should display only topics linked to those subjects. If no subjects are selected, the demo_video dropdown should be empty.

class DemoVideos(TimeStampModel):
    demo_video = models.ForeignKey(
        Topic,
        on_delete=models.CASCADE,
        null=True,
        blank=True,
        related_name='demo_videos'
    ),
    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')


class Special(TimeStampModel):
    name = models.CharField(max_length=50, blank=False)
    subject_id = models.ManyToManyField(
        Subject,
        related_name="buy_med_special",
        blank=False,
        limit_choices_to={"is_active": True, "is_special": True},
        help_text="Select subjects associated with this special.",
    )

    demo_video = GenericRelation(
        to=DemoVideos,
        related_query_name="special_demo_videos",
    )
    def __str__(self) -> str:
        return f"Special: {self.name} id: {self.id}"




topic model:

class Topic(TimeStampModel):
    subject = models.ForeignKey(
        Subject,
        on_delete=models.CASCADE,
        blank=True,
        null=True,
        related_name="topics",
        limit_choices_to={"is_active": True},
    )

Welcome @Sahil42jha !

First, a side note: In the future, please keep the title short. Use the body of the post to provide the full description, don’t try to post everything in the title.

Now, to do this, you need to use some JavaScript that will detect the change of a field and update other fields.

There have been multiple discussions in the forum on this topic, I suggest you start with Django 5: Within the form, filter data with another field of the same form - #4 by KenWhitesell, and also see Django: how to choose from a list based on the previous selection?
If you search through the forum, you’ll find other threads as well on this topic.

Thanks @KenWhitesell will go through mentioned forums.