Hi All..

I've a performance problem with manyToMany relations..
I've a model like this:


class Story(models.Model):
    title = models.TextField(verbose_name =
"titolo" ,max_length=200,core=True)
    abstract = models.TextField('sommario',max_length=400,core=True)
    text = models.TextField(verbose_name = "testo",core=True)
    id_section =
models.ManyToManyField(Section,verbose_name="Sezione", null = False)
    ...

and the Section model is:

class Section(models.Model):
    id_site = models.ForeignKey(Site,verbose_name="Sito")
    section_name = models.CharField(max_length=100,core=True,
verbose_name="Nome")
    order = models.IntegerField(default=0, verbose_name="Ordine")
    section_father = models.ForeignKey('self',blank=True,null=True,
verbose_name="Sezione superiore")
    ....

In my template, every time I make:

    {{ story.id_section.section_name }}

it seems that django make a new query in the 'section' table...
Is there a way to populate my Story object with the section values
just one time?
In the mysql log file I have a lot of identycal query...


--~--~---------~--~----~------------~-------~--~----~
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