Hi,

I have the following models:

class Memory(models.Model):
    partnum = models.CharField(max_length=30)
    size = models.IntegerField()

    def __unicode__(self):
        return self.partnum

class Motherboard(models.Model):
    name = models.CharField(max_length=20)
    sockets = models.IntegerField()
    modules = models.ManyToManyField(Memory, through='MemModules')

    def __unicode__(self):
        return self.name

class MemModules(models.Model):
   memory = models.ForeignKey(Memory)
   motherboard = models.ForeignKey(Motherboard)
   count = models.IntegerField()


I can use the following commands to access all the memory modules
related to a specific motherboard:

>>> from mike.test.models import *
>>> m = Motherboard.objects.get(name="C7X58")
>>> print m.name
C7X58
>>> mods = m.modules
>>> mods
<django.db.models.fields.related.ManyRelatedManager object at
0x976344c>
>>> for i in mods.all():
...    print i.size
...
1
2

My question is - How can I access the extra fields stored in the
intermediary table?  In this case the count field?  I've been
searching through the Django documentation but can't seem to find any
examples.

Thanks for any help!

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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to