?page=2
The page=2 here is passed as url parameters. You can get it in request.kwargs in Django view. It is generally used to pass ordinary parameters:
request.kwargs['page'] # 2
/page/2/
This "2" is the ontology of the url. This usage is generally used with Django class-based view to automatically parse the Django model object corresponding to this "2"
For example url.py:
from django.views.generic import DetailView
class YourView(DetailView):
def get_object(self, queryset=None):
pk = self.kwargs.get(self.pk_url_kwarg, None)
if int(pk) == 0:
return None
return super(Yourview, self).get_object(queryset)
The get_object method here does something similar, so that you can access the object directly through self.object
You can refer to the official documentation https://docs.djangoproject.com/en/1.7/topics/class-based-views/generic-display/
It feels like it has nothing to do with the paging class. It’s just a question of how to pass the page parameter. It can be passed through URLConf or created through QueryString. After getting this parameter, use pagination to implement paging
The scenarios for these two usages are different
?page=2
The page=2 here is passed as url parameters. You can get it in request.kwargs in Django view. It is generally used to pass ordinary parameters:
request.kwargs['page'] # 2
/page/2/
This "2" is the ontology of the url. This usage is generally used with Django class-based view to automatically parse the Django model object corresponding to this "2"
For example url.py:
views.py:
The get_object method here does something similar, so that you can access the object directly through self.object
You can refer to the official documentation
https://docs.djangoproject.com/en/1.7/topics/class-based-views/generic-display/
It feels like it has nothing to do with the paging class. It’s just a question of how to pass the page parameter. It can be passed through URLConf or created through QueryString. After getting this parameter, use pagination to implement paging