I have the same problem. Does anyone have an example of what we the code in the view would look like?
On Sep 25, 2:37 pm, SnappyDjangoUser <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > Am I on the right track with my M2M model definition (which includes > an intermediate table)? I still need help with 2 questions: > > 1. How do I create a Model Manager? > > 2. Within a view, what is the best way to add entries into tables that > have a M2M relationship with an intermediate table? I've been reading > the following documentation with command line options, but I have not > been able to put a cohesive view method together for my models above. > Is there any examples of how to add to M2M tables within a > view?http://docs.djangoproject.com/en/dev/ref/models/relations/http://www.djangoproject.com/documentation/models/m2m_intermediary/ > > I'm a bit stuck at the moment, so I would really appreciate any > guidance you can provide. > > Thank you! > > On Sep 24, 11:53 am, SnappyDjangoUser <[EMAIL PROTECTED]> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---