class Category(models.Model):
name = models.CharField(max_lenth=50)
class SubCatergory(models.Model):
parent_category = models.ForeignKey(Category)
name = models.CharField(max_length=100)
class Product(models.Model):
sub_category = models.ManytoManyField(SubCatergory)
name = models.CharField(max_length=100)
Is the above best practice for organising relationships or should I combine the models for cat/sub cat to make it more like a tagging system? For example a product can be tagged with “Cat A” and “Sub Cat A”. The app won’t need to have categories added to it after launch.
This really depends on your requirements. If you’re writing a program for a system that only requires a two-level hierarchy then what you’ve done is perfectly fine. If you can imagine a time where you might have a more complicated hierarchy then combining them does make sense.
You mention a ‘product’, which to me suggests that you want a strict hierarchy so your current models seem fine.