开发者

Multiple Get in django templates

Hi I have multiple pagination in a single page. Lets say, I am displaying two lists. list1 and list2. in the views I have paginated them using django paginator and I GET two variables list1_page and list2_page.

now my template looks like this

{{ list1_page_obj.object_list }}
{% if list1_page_obj.has_next %}
<a href='?list1_page={{ list1_page_obj.next_page_number }}'>NEXT</a>
{% endif %}

{{ list2_page_obj.object_list }}
{% if list2_page_obj.has_next %}
<a href='?list2_page={{ list1_page_obj.next_page_number }}'>NEXT</a>
{% endif %}

now the thing is if I am on the second page of list1 and I click on NEXT page of list2 I get the next page 开发者_开发问答of list 2 but the first page of list1 is displayed.

basically if I am on http://foo.com/?list1_page=xx and I click on NEXT on list2 I get http://foo.com/?list2_page=yy I want it to redirect to http://foo.com/?list1_page=xx&list2_page=yy


I guess, your pagination function have the problem... I do not know your pagination function variable names but probably you are making the mistake in;

next_page = int(request.GET.get('page', 1))

where 'page' is the variable that keeps your page info, so in your code there must be two paginator block with these two lines included separately...

lsit1_page = int(request.GET.get('list1_page', 1))

and

lsit2_page = int(request.GET.get('list2_page', 1))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜