Hi Everyone, I need some guidance with adding table entries where I have a M2M table relationship. I am adding entires via a Quote ModelForm. The problem is that I am getting the following error when submitting the form: "Cannot set values on a ManyToManyField which specifies an intermediary model. Use QuoteHasProduct's Manager instead."
I have 2 questions: 1. How do I create a Manager to add entries to the QuoteHasProduct model? (see above error message) 2. My Quote ModelForm creates a nice multiselect box for the products selected in the M2M relationship. My problem is that I also have several additional fields in the QuoteHasProduct table (e.g. quantity and product_quote) and I need a way to enter values for them. Does anyone have a suggestion on a front end mechanism to select multiple products for an order and also enter the quantity and product_quote at the same time. I am hoping there is an easy way to do this within the ModelForms class. For reference, the Models of my tables are below: class Product(models.Model): idProduct = models.AutoField(primary_key=True) Vendor_idVendor = models.ForeignKey(Vendor, db_column='Vendor_idVendor', verbose_name = 'Vendor Name') Device_Family = models.CharField(max_length=90) Product_Number = models.CharField(max_length=30) Device_Description = models.TextField(blank=True) class Meta: db_table = u'Product' def __unicode__(self): return self.Device_Family class Quote(models.Model): idQuote = models.AutoField(primary_key=True, verbose_name='Quote Number') quote_date = models.DateField() quote_number = models.CharField(max_length=45, blank=True) quote_file = models.FileField(blank=True, upload_to='files/ orders/') products = models.ManyToManyField(Product, through='QuoteHasProduct') # filter_interface=models.HORIZONTAL class Meta: db_table = u'Quote' def __unicode__(self): return self.quote_number class QuoteHasProduct(models.Model): Quote_idQuote = models.ForeignKey(Quote) Product_idProduct = models.ForeignKey(Product) quantity = models.IntegerField() product_quote = models.DecimalField(max_digits=10, decimal_places=2) class Meta: db_table = u'Quote_has_Product' Thank you in advance for the guidance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---