On Sun, Jun 25, 2017 at 4:20 PM, Vijay Khemlani <vkhem...@gmail.com> 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 row in the table that has a Document_id and MetaData_id. That is
the document title and MetaData name I am trying to get so it can be
displayed in the admin screen for that particular row in the
DocumentMetaData table. I hope that makes more sense.

>
> If you want a particular DocumentMetaData to only refer to a single
> document and a single metadata then change the ManyToManyField for a
> ForeignKey
>

That is not what I want.

>
> If you do that then you can do self.document.title and
> self.metadata.name to access those fields.
>
> On 6/25/17, Mark Phillips <m...@phillipsmarketing.biz> wrote:
> > I have this class
> >
> > class DocumentMetaData(models.Model):
> >     document = models.ManyToManyField(Document)
> >     metadata = models.ManyToManyField(MetaData)
> >     metadatavalue = models.ManyToManyField(MetaDataValue)
> >
> >     def __str__(self):
> >         return "%s - %s" % (self.document, self.metadata)
> >
> > The Document class has a field called 'title' and the Metadata class has
> a
> > field called 'name'. How do I accesses these two fields from the class
> > DocumentMetaData so the string output is something like <document.title>
> -
> > <
> > metadata.name>?
> >
> > Thanks!
> >
> > Mark
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/
> CAEqej2NCVAp07CvESrUnR7k61UG4b0_q5OcaemfOrh%2B77mnTdQ%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CALn3ei0k-kV42aK%2BcT0%2By5jLGtaZOG3U2YPGT35j1nixJFxn
> 9g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEqej2Pe3rpuFb8Hy56W%3D%3DSc2j-Zk%3Dc90uAOWMibYZ5mocs2dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to