Since Django 1.7, you can use an extensible System Check Framework, which replaces the old validate management command. In this recipe, you will learn how to create a check if the ADMINS
setting is set. Similarly, you will be able to check whether different secret keys or access tokens are set for the APIs that you are using.
Let's start with the viral_videos
app that we created in the Using database query expressions recipe and extended in the previous recipe.
To use System Check Framework, follow these simple steps:
Create the
checks.py
file with the following content:# viral_videos/checks.py # -*- coding: UTF-8 -*- from __future__ import unicode_literals from django.core.checks import Warning, register, Tags @register(Tags.compatibility) def settings_check(app_configs, **kwargs): from django.conf import settings errors = [] if not settings.ADMINS: errors.append( Warning( """The system...