Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use slug instead of a full path for categories, add more prefetches

Pacu26ca75be18faa
diff --git a/saleor/product/urls.py b/saleor/product/urls.py
index 8f1f39accb..12ba89ed12 100644
--- a/saleor/product/urls.py
+++ b/saleor/product/urls.py
@@ -5,7 +5,7 @@ from . import views
urlpatterns = [
url(r'^(?P<slug>[a-z0-9-_]+?)-(?P<product_id>[0-9]+)/$',
views.product_details, name='details'),
- url(r'^category/(?P<path>[a-z0-9-_/]+?)-(?P<category_id>[0-9]+)/$',
+ url(r'^category/(?P<slug>[a-z0-9-_]+?)-(?P<category_id>[0-9]+)/$',
views.category_index, name='category'),
url(r'(?P<slug>[a-z0-9-_]+?)-(?P<product_id>[0-9]+)/add/$',
views.product_add_to_cart, name='add-to-cart'),
diff --git a/saleor/product/views.py b/saleor/product/views.py
index ec53cac55a..d3d17eb987 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -130,7 +130,8 @@ def category_index(request, slug, category_id):
def collection_index(request, slug, pk):
- collections = collections_visible_to_user(request.user)
+ collections = collections_visible_to_user(request.user).prefetch_related(
+ 'translations')
collection = get_object_or_404(collections, id=pk)
if collection.slug != slug:
return HttpResponsePermanentRedirect(collection.get_absolute_url())