python - how to add dynamic arguments to urls in django -


i have website ,i let user manager account .

in account page ,it show articles submitted .

to make simple ,i let can choose show how many articles in 1 page.by default show 10 articles in 1 page ,it done django pagination function ,if user want show 20 articles in 1 page, add arguments current urls .

for example : ?num=20

then second page url should ?num=20&page=2

the problem ,once click page next button ,the url change ?page=2,there no num arguments pass django.

and there more arguments need pass django ,like show articles in subject in sports,so should add 1 more arguments ,like

?num=20&sub=sport&page=2 

but how can make work?

all know give every argument parameter ,like

url(_(r'^post/(?p<num>\w+)/(?p<sub>\w+)/(?p<page>\w+)/$'), views.post, ), 

how can design url ? if have 5 arguments need post .

if use url arguments ?num=20&sub=sport&page=2 have them in request.get.

print request.get['num'], request.get['sub'] request.get['page']

you can create own variable like:

def test_func(request):    next_page_url = '%s?page=%s' % (request.path, int(request.get['page'] + 1) if 'page' in request.get else '%s?page=2' % (request.path)     return dict(next_page_url=next_page_url) 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -