python - How do I create a Django model field that evaluates based on other fields? -


I will try to describe my problem with a simple example that says I have the item's items < / Code> and each item is related to a certain type of category Now I can take any two items and type an item combo ItemCombo this item combo The combo category deals with a specific category called . Combo category is based on categories that are related to items, so I'm not interested in hardcoding combocategory in item code ItemCombo categories for items Will a virtual field evaluate from time to time in itemCombo ?

  class category (models.model): value = model Charafield (maximum_long = 1) class item (models.Model): value = model. Kharefild (max_long = 10) category = model Faircock (category) category combo category (model model): Category 1 = model. Category 2 = Model Förngi (category) value = model Cheerfield (max_land = 1) class itemCampo (model.model): item1 = model. Forngike (item) item 2 = model. Forninki (item) combocodes = model. Your model class is full Python classes, so that you can add attributes, Methods, and their properties:    Category ItemCombo (models.Model): Item 1 = Model.Arangi (item) Item 2 = Model.Againki (item) @ Property DayConstriction (self) : Returns .. # Some Madu-Jumbo item 1 and item 2  

Comments