0

I want to create a relationship between Shops and Categories where a shop might have multiple categories and was thinking how possible it is to create a list of Category objects in a variable inside the Shop object. Or what is the better approach?

class Category(models.Model):
    ...

class Shop(models.Model):
    categories = list(models.ForeignKey(Category,...))
    ...
shahwan42
  • 75
  • 9

1 Answers1

4

You might be referring to ManyToManyField relationship.

Might be related to: How do I make many-to-many field optional in Django?

Django docs: https://docs.djangoproject.com/en/2.2/topics/db/examples/many_to_many/

bgsuello
  • 582
  • 5
  • 12