You can use an extra select to get additional parameter 'main_section'
This is for MySQL and it's only sample
you need to test it in your DB to make sure, that it works

sub_select =  """SELECT section_name
                        FROM %(table_section)s as sc, %
(table_section_story)s  as st
                        WHERE  st.story_id  = %(table_story)s.id
                                    AND sc.id =
st.section_id
                        ORDER BY order
                        LIMIT 1""" % { 'table_section':
Section._meta.db_table,
                                              'table_section_story':
'myapp_section_story'  # Not sure!!!  see your DB actual table name
                                              'table_story':
Story._meta.db_table }

We don't create Story object here, we just get a dictionary with all
values we need in template

story = Story.objects.filter(pk=1).extra(select={'main_section':
sub_select }).values('main_section', 'other_field1', 'other_field2' )

In template:
{{ story.main_section }}
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to