checks.py 826 B

123456789101112131415161718192021222324252627282930
  1. from __future__ import unicode_literals
  2. from django.core.checks import Warning, register
  3. from mezzanine.conf import settings
  4. @register
  5. def check_context_processor(app_configs, **kwargs):
  6. issues = []
  7. name = 'mezzanine.pages.context_processors.page'
  8. if settings.TEMPLATES:
  9. loaded = any(name in config.get('OPTIONS', {}).get(
  10. 'context_processors', {}) for config in settings.TEMPLATES)
  11. else:
  12. loaded = name in settings.TEMPLATE_CONTEXT_PROCESSORS
  13. if not loaded:
  14. issues.append(Warning(
  15. "You haven't included 'mezzanine.pages.context_processors.page' "
  16. "as a context processor in any of your template configurations. "
  17. "Your templates might not work as expected.",
  18. id="mezzanine.pages.W01"
  19. ))
  20. return issues