Skip to content

Commit

Permalink
#621 Fix product page performance
Browse files Browse the repository at this point in the history
#607  Cache menu
  • Loading branch information
duker33 committed Oct 30, 2018
1 parent b65ddbc commit e3a534a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
6 changes: 4 additions & 2 deletions shopelectro/views/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ def get_images_context(self):
url_kwargs={},
request=self.request,
page=self.product.page,
products=models.Product.objects.all(),
product_pages=models.ProductPage.objects.all(),
products=models.Product.objects.filter(id=self.product.id),
product_pages=models.ProductPage.objects.filter(
shopelectro_product=self.product
),
)
)

Expand Down
46 changes: 25 additions & 21 deletions templates/layout/header.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load cache %}
{% load pages_extras %}
{% load se_extras %}
{% load static %}
Expand Down Expand Up @@ -114,29 +115,32 @@
</div>
</div>

<div class="nav-category-wrapper hidden-xs hidden-sm">
<ul class="nav-category list-unstyled">
{% for root in root_categories %}
{% comment %}Cache for a day{% endcomment %}
{% cache 86400 categories_menu %}
<div class="nav-category-wrapper hidden-xs hidden-sm">
<ul class="nav-category list-unstyled">
{% for root in root_categories %}
<li class="nav-category-item js-menu-item">
<a class="nav-category-link" href="{{ root.url }}">{{ root.name }}</a>
{% if root.get_children %}
<ul class="list-white nav-menu-dropdown">
{% for child in root.get_children %}
<li>
<a href="{{ child.url }}" class="list-white-link">
{{ child.name }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
<li class="nav-category-item js-menu-item">
<a class="nav-category-link" href="{{ root.url }}">{{ root.name }}</a>
{% if root.get_children %}
<ul class="list-white nav-menu-dropdown">
{% for child in root.get_children %}
<li>
<a href="{{ child.url }}" class="list-white-link">
{{ child.name }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
<a class="nav-category-link" href="{% url 'pages:flat_page' 'remont-akkumulyatorov' %}" title="Ремонт аккумуляторов">Ремонт аккумуляторов</a>
</li>
{% endfor %}
<li class="nav-category-item js-menu-item">
<a class="nav-category-link" href="{% url 'pages:flat_page' 'remont-akkumulyatorov' %}" title="Ремонт аккумуляторов">Ремонт аккумуляторов</a>
</li>
</ul>
</div>
</ul>
</div>
{% endcache %}
</div>
{% endif %}
</div>
Expand Down

0 comments on commit e3a534a

Please sign in to comment.