checks.py 970 B

123456789101112131415161718192021
  1. from django.core.checks import Tags, Warning, register
  2. @register(Tags.compatibility)
  3. def pagination_system_check(app_configs, **kwargs):
  4. errors = []
  5. # Use of default page size setting requires a default Paginator class
  6. from rest_framework.settings import api_settings
  7. if api_settings.PAGE_SIZE and not api_settings.DEFAULT_PAGINATION_CLASS:
  8. errors.append(
  9. Warning(
  10. "You have specified a default PAGE_SIZE pagination rest_framework setting, "
  11. "without specifying also a DEFAULT_PAGINATION_CLASS.",
  12. hint="The default for DEFAULT_PAGINATION_CLASS is None. "
  13. "In previous versions this was PageNumberPagination. "
  14. "If you wish to define PAGE_SIZE globally whilst defining "
  15. "pagination_class on a per-view basis you may silence this check.",
  16. id="rest_framework.W001"
  17. )
  18. )
  19. return errors