Re: How to list all parents and their children if any?
Hi,
You mentioned that you could have used a m2m between Connector and
Cable, but it sounded that you opted out. I could be wrong, but to get
the desired report to display, I think you may need to revisit your
models.py and use the "_set" used in m2m relationships.
_mario
On Nov 28, 11:50 pm, adelaide_mike <mike.ro...@internode.on.net>
wrote:
> I have three models:
>
> class Connector(models.Model):
> connectorname = models.CharField(max_length=32)
>
> class Cable(models.Model):
> cablename = models.CharField(max_length=32)
>
> class Node(models.Model):
> connector = models.ForeignKey(Connector)
> cable = models.ForeignKey(Cable)
> node_specific_data = models.CharField(max_length=32)
>
> I wish to make a report displaying all Connector names at least once,
> and the Cable name that the Node model relates them to. If I did not
> need the nodespecificdata I could have used a many-to-many between
> Connector and Cable. Sadly I do need it.
>
> A Connector may have any number of related nodes, including none.
>
> I need to obtain a report displaying all connectors at least once,
> with their related cablename(s), if any, shown (on additional rows if
> necessary). Can I do this without resorting to raw SQL?
>
> Thanks (yet again)
>
> Mike
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home