I would like to set the default category to be whatever the parent's category is set to.
Here's the basic object model right now:
class Product(models.Model):
parent = models.ForeignKey('self', null=True, blank=True, related_name="variants")
category = models.ForeignKey(Category, related_name='products')
I would like to be able to do something like this:
category = models.ForeignKey(Category, related_name='products', default=get_parent_category)
But I don't know how to go about getting the parent's category (what would that method look like?). Is there a better way to go about it?
(question is related to this one)