> That's works really thank you for your time, learned a very good thing
> today, 1 week im on this X) . Already look a little to Prefetch() function
> but haven't understand how to use it in my case^^
>
Don't feel that bad. Prefetch() stumped me for a long time until I saw a
post about it on this
That's works really thank you for your time, learned a very good thing
today, 1 week im on this X) . Already look a little to Prefetch() function
but haven't understand how to use it in my case^^
I have replaced my {% with currscat=categ.getscateg %} by {% with
currscat=categ.souscategorie_set.
>
> ###
> # template code - I removed the blank lines and reduced the indentation
> for readability in an email.
> ###
>
> {% for categ in categs %}
> {% with currscat=categ.souscategorie_set.all %}
> {{categ.nom}}
> {% if currscat %} # This line hit database
>
Sorry,
The reason that you are seeing multiple hits on the database is due to the
way that your template loops are built. The {% with %} statements are
calling a method on your model, which is returning a fresh queryset for
every iteration of the for loop (which is then compounded by the inner {%
with %}
I post here my real models for better comprehension (and have cleaned it
this morning with an abstract class)
class Rubrique(models.Model):
nom = models.CharField(max_length=30)
slug = models.SlugField(max_length=100)
page = models.CharField(max_length=50, null=True)
description
duplicated queries as in exactly the same or with different parameters? If
they hace different parameters it sounds like something you can resolve
with select_related
https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related
Either way, you would need to post you rmodels and quer
Yes sorry, deleted it ^^
class Categorie(models.Model):
nom = models.CharField(max_length=30)
slug = models.SlugField(max_length=100)
visible = models.BooleanField("Visible",default = False)
def getscateg(self):
return self.souscategorie_set.all().filter(visible = True
Did you modify your models before sending them out? You don't show any
foreign key relationships, but your queries indicate otherwise.
-James
On Nov 7, 2015 8:37 AM, "V1ce" wrote:
> Hi,
>
> I got a lot of duplicated queries (in django debug toolbag) when i load my
> menu tabs , actually it's nor
8 matches
Mail list logo