django - Best method to store list of foreign keys in a model? -


for example, let's i'm running online meat shop. orders come in "parcels", contain various types of meat.
models this:

class parcel(models.model):     customer_address = models.charfield()     date_wanted = models.datefield()     meats = ? class meat:     name = models.charfield()     cost = models.decimalfield(4, 2) 

so, have set of meat objects represent different meats can put in parcel. then, parcel contains large amount of meat objects, address needs shipped to, etc.
how store unknown amount of foreign keys in django model?

this classic many-to-many relationship.

https://docs.djangoproject.com/en/dev/ref/models/fields/#ref-manytomany


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -