Reputation: 9765
Supposing, I've got a URL pattern like this:
urlpatterns = [
...
url(r'^mylist/(?P<offset>\d+)/$', MylistView.as_view(), name='mylist'),
...
]
My view class:
class MylistView(ListView):
template_name = 'mylist.html'
def get_queryset(self, *args, **kwargs):
offset = ... # What should I type here?
entries = models.MylistEntry.all()[offset:offset+10]
return entries
How do I access to the URL parameter offset
within the method get_queryset
? I've checked the variables args
and kwargs
are empty.
Thanks for advance!
Upvotes: 7
Views: 2052
Reputation: 3941
Use self of get_queryset method for fetch url parameter
self.kwargs.get('offset')
Upvotes: 14