Many-to-many relation to a two models where one has a foreign-key relation to the other

Hi, all.
I’m somewhat new to programming, and I’m sure there’s a specific name for what I need to do, but please bear with me and my ignorance.
I want to define a table of Services “class SKU” and for each service a user can select zero or more categories detailing specs for the given service in question. Each category would have a list of choices the user can choose from related to the category.
Example:
Service: Subtitling
Category: Script Availability
CategoryChoices: (None, With Script, Master Template)
Service: Subtitling
Category: SDH
CategoryChoices: (None, SDH, CC)

So, a user specifying an SKU, would choose for instance category Script Availability with choice “None” and Category SDH with CategoryChoice “CC”

If these categories were predefined, I know this would be a simply many-to-many relationship with the choices specified in tuples. But given that these category and choices will be defined by each user dynamically, What is the optimal relation I can define. Should SKU have a manu-to-many relation with Category or with CategoryChoice? Or is there a better way?

class Category(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)

class CategoryChoice(models.Model):
category = models.ForeignKey(
Category, on_delete=models.CASCADE, related_name=“choices”
)
choice = models.CharField(max_length=255)
description = models.TextField(blank=True)

class SKU(models.Model):
uid = models.CharField(max_length=255, unique=True, blank=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True)

Welcome @psychlopes !

From what you describe, this is a case where Category has a ForeignKey to SKU.

Why are you thinking that SKU needs to have a many-to-many with Category? Is there some aspect of this that is not included in the current description?

Thank you for replying, Ken.
My issue is that if Category has a foreign key to SKU then how can I specify in SKU what the selected choice for that category is for a given SKU?

Like in the example above, I want the user for a given SKU to select a category and for that category choose from probably a radio button group the choice associated with it.

Like:
SKU (name : Subtitling with CC) , Category: SDH, selected choice for that category “CC”

Also, note that a category might be in multiple SKUs and an SKU might have multiple Categories associated with it. So, I’m guessing it’s a many-to-many relation , not foreignkey?

What I’m thinking of was something like this and I want to know if this is the optimal way to do it:

class SKU(models.Model):

uid = models.CharField(max_length=255, unique=True, verbose_name="UID", blank=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
categories = models.ManyToManyField(
    Category, related_name="services", through="ServiceCategory"
)

class ServiceCategory(models.Model):

service = models.ForeignKey(SKU, on_delete=models.CASCADE, related_name="services")
category = models.ForeignKey(
    Category, on_delete=models.CASCADE, related_name="categories"
)
choice = models.ForeignKey(
    CategoryChoice, on_delete=models.CASCADE, related_name="choices"
)

That’s what I didn’t see in the original description.

Yes, in this situation, a ManyToMany between Category and SKU is appropriate.