KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to set a field default value based on other field selection that is foreign. Basically, these are the classes: class Product(models.Model): description = models.CharField('Description', max_length=200) price = models.FloatField('Price') class Sell(models.Model): product = models.ForeignKey(Product) price = models.FloatField('Price') Each "Product" has a default price (or suggested price), so when the user, in Admin pages, want to add a new Sell and he/she choose a product, I need to copy dynamically from Product.price to Sell.price the suggested price. I cannot use "save" method because the user can change at that moment. Is it necessary to use JavaScript explicitly? or Is there an elegant way in Django to do that?
Tags (comma-separated)
Save Edits
Cancel