-
Website
http://blog.awarelabs.com -
Original page
http://blog.awarelabs.com/?p=84 -
Subscribe
All Comments -
Community
-
Top Commenters
-
williyamb
1 comment · 1 points
-
Malcolm Tredinnick
2 comments · 1 points
-
Seo Company
1 comment · 1 points
-
boston movers
1 comment · 1 points
-
rasiel
1 comment · 1 points
-
-
Popular Threads
Thanks for sharing.
Maybe something like the standard pagination method documentation but how to use this digg style pagination: http://docs.djangoproject.com/en/dev/topics/pag...
You don't put anything in views. The source download has everything you need, including an example.
This implementation is significantly different than the standard one in that it does not deal with views.py. Just take the query you currently have coming back from views.py and stick it in the tag call in your template.
The only parameter you should be passing through views.py is the current page (integer).
If you want to help people, as I'm sure you do... more detailed documentation is required... especially for newbie Django peeps.
I've updated the post with more details. Hope it helps. What were you having trouble with? Usually if you post the specific problem in the comments you'll get one of the awesome readers to drop by with an answer.
- Paul
Thanks for the update...
I found that by putting href="?page={{ page }}" in the pagination.html file instead of
href="/{{ pagination.view }}/{{ page }}/" you omit the need to include the url path as an argument... this is especially helpful if you are looking at, say, a list of Y's that are related to the Nth X object. This way the dynamic path (e.g. path/XN) can be omitted. It would otherwise have to be passed into the template by the view.
What were the reasons you chose to the convention urlpath/p/ over the convention ?page=p ?
I'm a Django newbie ;p
Thank you.
"No messy URLs to configure" how do you pass the page no without configuring the url?
After an hour or two of slamming my head into my desk, I finally realised that the idea of this is to have the paginator do all the paging for you [including the ORM calls]. Then I realised your /strict/url/s are not actually suitable for my paged search page and I'm going to have to modify it anyway.
Would have been so much easier for you to explain how it works, than it was for me to spend time discovering it's not what I'm looking for.
{% paginate "[dynamic URL here]" items current_page 50 10 paged_items %}
If you're asking for variable defined URLs then I suggest adding a resolve context variable call around the URL variable. Next release i guess.... hopefully your head will feel better by then.
<img src="http://i35.tinypic.com/2u78t3d.jpg" border="0">
PS: Note I didn't ask, "Why would you need dynamic pagination URLs..."
I am trying to use your pagination code on a search page.. so I need this sort of thing -
site/search/?s=bla&show=all&threshold=2days&page=3
Is this possible using "a resolve context variable call" (don't know what that is) ?
{% paginate "site/search/bla/all/2days/" items current_page 50 10 paged_items %}
The current page you will still have to carry around in the context. Pete's comment below is addressing this I think.
Not sure how much experience you've had passing parameters via URL but its a very powerful tool in Django.
I have eliminated querystrings from my application where possible, but when it comes to searching I would actually prefer a query string.
You suggested changing my URL to:
{% paginate "site/search/bla/all/2days/" items current_page 50 10 paged_items %}
But how exactly is that going to work? How is "site/search/bla/all/2days/" going to insert the parameters specified by the user doing the search? ie..
site/pictures of cats and dogs/bla/videos-only/2weeks
............
There absolutely must be a simple way to modify your script to support any kind of url, and I guess I am forced to find it myself and modify your script. I shall post the results here when I get around to it.
All that aside, thanks for your effort. I'm in a better position with your code than I would be without it, so for that I am grateful.
I'm trying to get the pagination widget to display in one template block and the page data to display in another template block.
Is there a way to share the "variable" of paged data across two blocks easily or do I need to create some sort of global in the paginaton tag and pass that across to the context of the other block?
Great work.
I posted a modified version of the pagination.html that can be used with any of the css files from here: http://mis-algoritmos.com/2007/03/16/some-style...
You can find the modified version of pagination.html here: http://meppum.com/media/blog_media/pagination.html
http://code.google.com/p/django-pagination/
and
http://code.google.com/p/django-sorting/
DO NOT WASTE YOUR TIME trying to understand this templatetag.
It might actually work well, but with practically no documentation and no complete examples you're bound to loose a lot of your valuable time.
I looked over the other code and it looks good. Go for it... sorry my startup has taken time away from my ability to maintain this code, a year is a good run though.
PS: The frustrated user above doesn't sound like he/she even tried the code before passing judgment. I hope I'm wrong.
Thanks
1) Code as-is will not run with Apache/WSGI, because wsgi does not allow writing to stdout. To fix this, remove 'print' statements in code.
2) If you add:
view = template.resolve_variable(self.view, context)
to PaginationNode.render(), you will be able to pass 'current_url' as context-variable also, similary to page index
3. As meppum posted, using alternative template/css is very good idea
http://www.gamejumble.com/category/action/
Wow, I love the result.
I'd love to use this but can't figure out how to get it working. Could you post a complete example, eg view, url, template + any thing else necessary.
Thanks
http://www.meowcode.com/django/digg-style-pagin...
I tried to make it step-by-step, let me know how does it works for you in comments there.