0

I've got this code

def category_view(request, path, instance):
    if instance is not None:
        categories = instance.get_ancestors(include_self=True)
        category_descendants = instance.get_descendants(include_self=True)
        product = ProductInStore.objects.filter(product__product_category__in=category_descendants).order_by('-created_at')
        paginator = Paginator(product, 9)
        page_number = request.GET.get('page')
        page_obj = paginator.get_page(page_number)


        context = {
            'categories': categories,
            'product': product,
            'page_obj': page_obj,
        }

        return render(request, 'ecommerce/category_view.html', context=context)
    return render(request, 'ecommerce/no_category.html')

and this url

    url(r'^kategorie/(?P<path>.*)', mptt_urls.view(model='categories.models.EcommerceProductCategory', view='ecommerce.views.category_view', slug_field='slug'), name='category_view'),

When i put category/categoryx/ it works, but when i put category/categoryx it looks for another category. Categoryx/ != categoryx

Do you have any idea how to redirect the path without trailing slash to the one with trailing slash?

Jakobkubek
  • 77
  • 1
  • 6

0 Answers0