我有 2 个模型如下
class Product(models.Model):
product_name = models.CharField(max_length=100)
product_weight = models.CharField(max_length=30)
class ProductImage(models.Model):
product = models.ForeignKey(Product, on_delete=models.DO_NOTHING)
image = models.ImageField(upload_to='/images/{product_id}/', blank=True)
Run Code Online (Sandbox Code Playgroud)
如何在 ProductImage 模型中提取 product_id?
提前致谢。