Re: Retrieve field values from ManyToMany field in model

2017-06-28 Thread Mark Phillips
Melvyn, Thanks for your response. My original question was how to get the string names for the metadata and document out of the many to many table in the __str__ model method. I was able to accomplish this by the following class DocumentMetaData(models.Model): document = models.ManyToManyFiel

Re: Retrieve field values from ManyToMany field in model

2017-06-26 Thread Melvyn Sopacua
On Sunday 25 June 2017 15:08:25 Mark Phillips wrote: > I have this class > > class DocumentMetaData(models.Model): > document = models.ManyToManyField(Document) > metadata = models.ManyToManyField(MetaData) > metadatavalue = models.ManyToManyField(MetaDataValue) That design is wrong.

Re: Retrieve field values from ManyToMany field in model

2017-06-25 Thread Mark Phillips
On Sun, Jun 25, 2017 at 4:20 PM, Vijay Khemlani wrote: > A DocumentMetaData instance may be associated with multiple documents > and multiple metadata according to your model, so your question is > ambiguous. > Sorry about the confusion. When I create a DocumentMetaData, then there is a single r

Re: Retrieve field values from ManyToMany field in model

2017-06-25 Thread Vijay Khemlani
A DocumentMetaData instance may be associated with multiple documents and multiple metadata according to your model, so your question is ambiguous. If you want a particular DocumentMetaData to only refer to a single document and a single metadata then change the ManyToManyField for a ForeignKey I