Models.py, From django admin what I do is I can add a product to Featured but the problem is when I select a product in admin to make featured I want to automatically inherit that product's image url which was uploaded when that product was created.
class Product(models.Model):
seller = models.ForeignKey(Seller, on_delete=models.CASCADE)
title = models.CharField(max_length=120, primary_key=True)
image = models.FileField()
def __str__(self):
return self.title
class FeaturedProduct(models.Model):
db_identification = models.CharField(max_length=120)
featured = models.ForeignKey(Product, on_delete=models.CASCADE)
photograph = How do I inherit it automatically from foreignkey product selected?
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.db_identification