many to many vs new object with compound foreign keys in django -


i have seen many many relationships expressed explicitly in model like:

class pizza(models.model):     toppings = models.manytomanyfield(topping, blank=true, null=true) 

i have seen people use object compound object this

class pizzatopping(models.model):     pizza = models.foreignkey(pizza)     topping = models.foreignkey(topping) 

is there more preferable method of two? if so, why?

example number 2 used when have additional fields in intermediary table (which example not have). example number 1 suffice when don't.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -