On 5/4/2009 6:36 PM, nbv4 wrote: > > > On May 4, 12:03 am, George Song <geo...@damacy.net> wrote: >> On 5/3/2009 8:17 PM, nbv4 wrote: >> >> >> >>> On May 3, 3:51 pm, Ramiro Morales <cra...@gmail.com> wrote: >>>> On Sun, May 3, 2009 at 4:26 PM, nbv4 <cp368...@ohio.edu> wrote: >>>>> Everything is fine and dandy, except for when I want to use the admin >>>>> interface to create a new route. All I see is a dropdown for the >>>>> "often" field. I have to go to the RouteBase section of the admin to >>>>> add the rest. Normally if there is a ManyToMany field, in the admin >>>>> interface there will be a little green plus sign that you can use to >>>>> create a new object to attach. If the "through" option is used, it >>>>> doesn't show up. Why? Is there a way to change this behavior? Is this >>>>> a bug or is there a reason for this? >>>> See >>>> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-... >>> Gee whiz thanks a lot. >>> I've got one more problem. How do I access the information from within >>> that intermediate class? >>> I can do: >>> ---------- >>> r = Route.objects.get(pk=1) >>> r.bases.all() >>> -------- >>> and r will be a list of all bases. From within that Route object (r), >>> is there anyway to get access to the RouteBase attributes? Something >>> like r.sequence? >> The intermediate class is no different than any other many-to-one >> related classes: >> <http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects> >> > > > It's not possible to get those attributes unless I make another query? > Basically I have one object that has a TON of related fields, some > ForeignKey, some ManyToMany. Is it possible to pass just one instance > of that one object to a Template and have access to the whole shebang > through that one object? The link you gave me suggests that, but it > just doesn't seem right...
Well, it is possible. Having an intermediate table for m2m suggests you need two pieces of information to locate a specific record. If you just to loop through all RouteBase objects for a certain Route object, you can just do: {{{ for rb in r.routebase_set.all(): do_something_with(rb.base) do_someotherthing_with(rb.other_rb_field) }}} -- George --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---