1👍
✅
I would replace your url.py by something like this:
url(r'(?P<keyword>\w+)/$', BoxesView.as_view())
This changes your address into an url parameter which you can then access the in your methods like this:
def get_queryset(self):
url = self.kwargs['keyword']
queryset_list = Post.objects.all().filter(category=url)
0👍
You can use this to get the name of the view
url = resolve(self.request.path_info).url_name
UPDATE: Added “self.” which is needed when using generic views. And don’t forget to import:
from django.core.urlresolvers import resolve
- Attribute error 'LoginForm' object has no attribute 'cleaned_data' where login is carried out by mail and password
- Passing csrf token through $.ajax() data not working
- In django, values(*field) doesn't give all values of ForeignKey field with sliced queryset
- How to return an empty form in ModelFormMixin
Source:stackexchange.com