frankban / django-endless-pagination

This project is deprecated: please use https://github.com/shtalinberg/django-el-pagination
MIT License
251 stars 108 forks source link

-1 -2 -3 -4 Page URLS #87

Open davidrenne opened 9 years ago

davidrenne commented 9 years ago

I had a requirement to change my urls from /?page=1 ?page=2 etc etc to a slug folder like -1/ -2/ -3/

I implemented it like this:

https://github.com/davidrenne/django-endless-pagination/commit/f490a7698ee360987a9e92155f3c546400a07871

It is a bit hacky because I am translating the page parameter from URLS.py

    url(r'^$', views.index, name='website_profiles_home'),
    url(r'-(?P<page>\d+)/$', views.index_page, name='website_profiles_home_next'),

Where my original use case was views.index paginating just fine.

I created a dash version which had this contents for the stubbed view:

def index_page(*args, **kwargs):
    args[0].GET = args[0].GET.copy()
    args[0].GET['page'] = kwargs['page']
    return index(*args, **kwargs)

It might be nice if someone could use your base tool like this, but a little less hacky where you can receive the page from a stub view that you can import from endless and a stub URL from endless which would setup the fake page.

Just an idea if anyone knew, but URLs which have a folder name would rank higher than those with a get parameter with SEO.

Close if you want, but I wanted to suggest something more elegant that you guys can support maybe as a configuration.

davidrenne commented 9 years ago

https://github.com/davidrenne/django-endless-pagination/commit/c066c754fd54b47c1a16de34e79cde71bd9f5e9b

Added setting where I had a hard coded True for testing.