I have one Product Model that has a FK to price, as one product can contain many prices. But I also want to be able to pick which one of those many prices should be the actual price, therefore I have both price (in Product Model) and product (in Price Model) to accomplish this. Consider these following models:
class Product(models.Model):
name = models.CharField()
price = models.ForeignKey('Price', blank=True, null=True, related_name='Product')
class Price(models.Model):
amount = models.IntegerField()
product = models.ForeignKey('Product', related_name='product')
This works fine although I am having problem filtering the prices in the drop down menu. It gives me all the prices instead of just the prices that pertains to that product. Tried
limit_choices_to
but that doesn't seem to work with dynamic values.
I have also come across this patch: http://code.djangoproject.com/ticket/2445
Not sure what the best solution would be here. Would appreciate some pointers, thanks!