[Answer]-Django; limit Subcategory to a certain Main Category

1👍

You can use limit_choices_to argument: https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to

class Item(models.Model):

    name = name = models.CharField(max_length = 75)
    sub_category = models.ForeignKey(
        'ItemSubcategory', 
        limit_choices_to={'ItemCategory': 'Food'}
    )

Just to give you the basic idea.

Leave a comment