I am doing a project, in which I need the data of a model to be used in another.
The first models is this:
class Product(models.Model):
name = models.CharField(max_length=255)
price = models.FloatField()
photo = models.ImageField(upload_to='products/photos')
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
In the second, the offers, it would be the same data but with a new one, new_price.
How would the offer models look?
Cheers!
Could be:
In this way, when you create an offer, you pass the product along with the price of the product on offer. You just have to configure the relationship according to the behavior you want and add the additional fields you need.