New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how django-filter works with django-pagination #13
Comments
Very, very useful. Thank you. |
I'd suggest to document how this works with django-sorting too. Unfortunately django-sorting needs to go before pagination and doesn't support the 'as' keyword, so we are not able to do something like this:
Filed upstream at http://github.com/directeur/django-sorting/issues/#issue/4. |
Get this issue when I try the above. http://code.google.com/p/django-pagination/issues/detail?id=59#c0 Any ideas about what it might be? |
There is a problem with django-pagination: when you are, say, at page 5 and you apply a filter, the filter pass the "page" GET variable too, so in the filtered page you are already at page 5, that is wrong. Is there a way to exclude from the url the variable that django-pagination use when apply a filter? Hope this make sense... |
mdgart, I solved the page variable issue on the client with jQuery and the jQuery Back Button & Query (BBQ) library. See: http://benalman.com/code/projects/jquery-bbq/docs/files/jquery-ba-bbq-js.html
When the user clicks a filter link, javascript forces the get parameter of "page" to 1. In my example, all my filters are displayed as links, located within a div with an id of "changelist-filter". You will need to change your jQuery selector as appropriate. Hope this helps. |
mdgart, jonathonadler, I solved the page variable problem in a slightly different way that avoids relying on javascript: simply don't pass the 'page' parameter to the FilterSet. For example, based on the example in the docs: |
Very neat solution richardbarran, thanks! |
Thanks. I thought of patching the documentation to talk about django-pagination, but I have a small problem: what format is the documentation in? :-( |
Richard, it is rst but needs to be processed using sphinx (http://sphinx.pocoo.org/). |
The moment I use autopaginate tag, I get "object of type 'fooFilter' has no len()" typeerror. I'm sure I've got the enurable result, because I can loop though it and display the objects without using django-pagination. How can I fix that? Thanks! |
Excellent, saved me a lot of time thanks. |
Could you give me github links to django-pagination and django-sorting which work together, I tried some of these repositories without success. I get a : TemplateSyntaxError at /ads/search/ using this template
Thanks ! |
Sorry, I haven't used django-sorting so can't really help. Good luck! NB
|
so, here is a working pip requirements example for my previous question: django-filter==0.5.3 |
Try to use my fork: |
Does anyone know if using pagination and sorting with django-filter is possible using generic views? I see from these examples that the generic view method isn't being used. |
If I understand your question, it's possible, I use it here: https://github.com/ouhouhsami/django-geoads/blob/master/geoads/views.py |
In case anyone is interested, I wrote a much more complete replacement for django-sorting, called django-sorter: http://django-sorter.readthedocs.org/ |
As part of getting on top of the issue tracker, I'm going to close this one. It's more than 2 years since the last comment. If anybody wants to send in a pull request updating the documentation showing integration with current pagination/sorting solutions I'd be really happy to review, but short of that I'll come back to this next time it comes up IRL. I hope that makes sense. |
Thanks!!! |
They both work well together, it took me a while to fiddle it out. Based on the example in the docs:
The key is that you have to use pagination's as argument.
The text was updated successfully, but these errors were encountered: