Django - Object with many categories and many subcategories -
i have been struggling model this. im developing directory of companies in music industry. have data base of 500 companies. have categories: audio, video, ilumination, stages, music intruments, talent, schools , dj.
this categories have subcategories. - audio: recording, installation, rent, retail - video: installation, rent, retail - ilumination: installation, rent, retail - stages: bars, discos, theaters, stadiums - music intruments: retail, rent - talent: manager, record label, booking - schools: audio, production, theater, dance - dj: booking, retail
many companies enter in many of categories, , inside categories enter in many subcategories.
example: company x sells video , audio products offer installation service audio products. company x - audio: retail, installation. - video: retail
in opinion how can manage design models????
thanks in advance.
this code far, wrong.
the following method simple way of solving problem, may not efficient way of doing solves issue whole.
models.py
class subcategory(models.model): name = models.charfield(max_length=255) def __str__(self): return self.name class category(models.model): name = models.charfield(max_length=255) sub_categories = models.manytomanyfield(subcategory, blank=true, default=none) def __str__(self): return self.name class company(models.model): name = models.charfield(max_length=255) categories = models.manytomanyfield(category, blank=true, default=none) sub_categories = models.manytomanyfield(subcategory, blank=true, default=none) def __str__(self): return self.name
Comments
Post a Comment