'How to remove Django MPTT trailing slash at the end?

I've set up a simple path for categories url

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

models.py

    def get_absolute_url(self):
        return reverse('ecommerce:category_view', kwargs={'path': self.get_path()})

using this documentation: https://pypi.org/project/django-mptt-urls/

but when i go into an url lets say

http://127.0.0.1:8000/ecommerce/category/x/

works just fine, but when i remove the trailing slash

http://127.0.0.1:8000/ecommerce/category/x

i get an error

AttributeError at /ecommerce/category/x

'NoneType' object has no attribute 'get_ancestors'

Do you have any idea how to not include the trailing slash?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source