Skip to content
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

"Cannot reorder a query once a slice has been taken." - Pagination is not supported #2

Open
vdboor opened this issue Jul 23, 2012 · 5 comments
Labels

Comments

@vdboor
Copy link
Member

vdboor commented Jul 23, 2012

Due to the use of jqTree, the tree should start with root nodes only. This breaks with pagination, causing the error:

Cannot reorder a query once a slice has been taken.

This happens because the adminlist_recursetree attempts to sort the tree on lft value. To really fix this issue, the next page should start with the first root too. That could be implemented by using a custom paginator on the parent admin.

@borgstrom
Copy link
Contributor

I believe I've just run into this issue while using django-fluent-pages.

Is there any way to work around it?

@vdboor
Copy link
Member Author

vdboor commented Jul 17, 2013

You can set list_per_page to a very high value, e.g. 5000.

Clearly, I have to look into this issue pretty soon.

@borgstrom
Copy link
Contributor

Since the ModelAdmin is part of django-fluent-pages can you please provide direction on where I should set the list_per_page value.

I'll subclass your ModelAdmin and register it instead of the original, but which one should I be subclassing to add the list_per_page value?

@vdboor
Copy link
Member Author

vdboor commented Jul 18, 2013

Glad you've asked. This turned out to be a bit less intuitive then I thought.
You can add the following code to a admin.py or __init__.py file:

from fluent_pages.admin import UrlNodePolymorphicAdmin
UrlNodePolymorphicAdmin.list_per_page = 10000

UPDATE: I've just released a new version of django-polymorphic-tree which includes this workaround.

FYI, The polymorhic admin is implemented by registering one class in the admin, and proxying the add_view, change_view and delete_view to your model admin. That's why the value needs to be set to that particular class.

Fun fact: both that logic and this package were originally part of django-fluent-pages, and got split out or were upstreamed.

@borgstrom
Copy link
Contributor

The workaround is working good. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants