[Fixed]-Assign field from related model as default in another model

1👍

✅

One solution is

class Bid(models.Model):
    product = models.ForeignKey(Auction, related_name='auction')
    current_amount = models.PositiveIntegerField()

    def save(self, *args, **kwargs):
        if not self.current_amount:
            self.current_amount = self.product.minimum_price
        super(Bid, self).save(*args, **kwargs)

Leave a comment