0
假設,我有這樣的URL模式:如何訪問Django中get_queryset的URL參數?
urlpatterns = [
...
url(r'^mylist/(?P<offset>\d+)/$', MylistView.as_view(), name='mylist'),
...
]
我的觀點類:
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
如何訪問的URL參數offset
方法get_queryset
內?我檢查了變量args
和kwargs
是空的。
感謝您的提前!