-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse for 'categories' with arguments '( path, instance)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['category/(?P<path>.*)'] #9
Comments
The error message is quite verbose: your url rule {% url 'categories' path=path %} By the way, you are doing something strange. Please read class Category(MPTTModel):
...
def get_absolute_url(self):
return reverse('gallery', kwargs={'path': self.get_path()}) The better approach for your code is this <a href="{{ instance.get_absolute_url }}?query=..."> |
thanks alex....i tried it ...but throws this error..'NoneType' object has no attribute 'get_descendants' somehow the instance becomes none.... here is the view def category(request, path, instance, extra):
|
Maybe this will help queryset = Product.objects.filter(category__in=instance.get_descendants(include_self=True)) if instance else Product.objects.all() |
It won't as it shows all products if instance is none...why the instance is becoming none when sending the query? |
So, probably the |
No its not ending with that.....though I have given as u said in the link ...when I click on it ...reloads the page with no instance |
The resolution fails when I append that query string....wonder why? |
Insert this in your views.py and tell me the output: def category(request, path, instance, extra):
print('Path: [{}]'.format(path))
slug = path.split('/')[-2]
print('Slug: [{}]'.format(slug))
if slug:
for candidate in Product.objects.filter(slug=slug):
print('Candidate slug: [{}]'.format(candidate.slug))
# ... your code following ... |
Ah, I think I got it... Still write the output |
list index out of range Traceback:
Exception Type: IndexError at /category/women |
the resolution fails when |
I've made some changes, try to update |
OK Alex....just keep this issue open for sometime...if incase |
updated...what changes did u make? |
what happens when i m sending request to category function from another template ...say header.html |
Time cures :) |
a href="{% url 'categories' path instance %}?query={{query.value}}">{{ query.value }}
why above error is coming when i am passing path and instance from the url ?
i have included path and instance in the context from the view
path = instance.get_absolute_url()
instance = instance
The text was updated successfully, but these errors were encountered: