Search code examples
pythondjangodjango-rest-frameworkwarnings

Silence a specific Warning in Django / Django Rest Framework


I want to silence a single warning in Django, when using Django Rest Framework with a default PAGE_SIZE setting, but no DEFAULT_PAGINATION_CLASS setting. I am in the exact situation presented by the error message as a case in which I can silence it: I want a PAGE_SIZE setting globally whilst defining pagination_class on a per-view basis, case in which the warning says "you may silence this check."

But I haven't figured out how to silence only this warning without silencing other warnings (that'd be done via this method).

The warning itself is here in the DRF source code.

Any help would be appreciated!


Solution

  • I found this in the Django docs, and, luckily, the warning had an id, so

    SILENCED_SYSTEM_CHECKS = ['rest_framework.W001']
    

    in settings.py did the trick.