-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Make DEFAULT_PAGINATION_CLASS None by default.
#5170
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e52d31d
Changes to the paginator defaults and settings
matteius a224b6b
DRF-5168 import warnings
matteius 420bc48
Add a system checks file
matteius 64bc395
more compatible import approach
matteius f34da6d
missing bactic
matteius 7a0a5c3
revised language and approach to import the system check
matteius dd8979d
Adjust doc wording
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Changes to the paginator defaults and settings
Require a default paginator be specified when using the page size setting. #5168
- Loading branch information
commit e52d31d09b1b4f2697ec03384be9e57f05c24b6e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
By setting
'DEFAULT_PAGINATION_CLASS': Noneis it not the case that "Defaulting the setting to specifiesPageNumberPagination" is simply removed, rather than Deprecated?Also, could I not set
PAGE_SIZEglobally and then just enable pagination per-view?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is saying that you cannot have set a default PAGE_SIZE setting without also setting DEFAULT_PAGINATION_CLASS. I believe the language of the second sentence could be improved but its trying to say that defaulting the variable DEFAULT_PAGINATION_CLASS to
PageNumberPaginationwas removed.The issue here is that the current default in 3.6 is that there is no page size set and PageNumberPagination doesn't have a pagination class defined, so you end up with a case where parts of the code thinks it is paginated but no pagination ever actually occurs . The point of this warning is to prevent users that rely on the current default of PageNumberPagination where it actually works for them because they set PAGE_SIZE and during their upgrade they would realize they need to specify both settings values in their project rather than rely on this former default. When it defaults to None it would disable pagination for those users otherwise.
More information here: #5168
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PageNumberPagination class defaults to the settings PAGE_SIZE and has
page_size_query_param = Noneso there is no way to change pagination by default without either setting PAGE_SIZE setting or sub-classing PageNumberPagination.The idea here is that going forward you would want to be explicit in setting a per-class Paginator that makes sense, or to use both defaults to enable pagination across the project space. I recall at Pycon that Tom wanted such a DeprecationWarning to ensure users that upgrade don't go from having pagination on in their project to disabled without any explanation. This concern would be specifically users that set a PAGE_SIZE setting but were relying on the default DEFAULT_PAGINATION_CLASS value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you bring up a good point about users that want to "set PAGE_SIZE globally and then just enable pagination per-view" -- In this case they would specifically be using PageNumberPagination in specific views and have a global PAGE_SIZE set. One option is to sub-class PageNumberPagination and set the page_size setting once on that class, then use that in the per-view instances. Open to refinement, but just stating the history of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matteius Thanks for the good replies.
... and ...
OK. That's the key.
My thought here is that we should remove the Deprecation warning but add a System Check for the same thing. (It runs once at start up and users can silence this if they really do want just
PAGE_SIZE.)We can then call out the change in the Release Notes and Announcement for 3.7 and the combination of the two would be good enough.
Does that sound OK to you? (Are you happy to write the system check?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this sounds like the right direction to head in. I just reviewed the system check docs and I feel comfortable converting this PR to that approach, but where do you suggest is the right file to implement the check method and register it? I was considering doing it in the compat.py file unless you have an alternate suggestion @carltongibson ?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matteius That sounds fine. (We can always move it later if needed.)
Thanks for the great input! (If you need any help let me know.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request has been updated to be current.