Project

General

Profile

Développement #18909

lors des tests lever une erreur si une variable non définie est utilisée dans un template

Added by Frédéric Péters over 7 years ago. Updated over 7 years ago.

Status:
Nouveau
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
23 September 2017
Due date:
% Done:

0%

Estimated time:
Patch proposed:
No
Planning:
Club:

Description

D'une discussion récente sur la liste django-developers, https://djangosnippets.org/snippets/646/

class InvalidVarException(object):
    def __mod__(self, missing):
        try:
            missing_str=unicode(missing)
        except:
            missing_str='Failed to create string representation'
        raise Exception('Unknown template variable %r %s' % (missing, missing_str))
    def __contains__(self, search):
        if search=='%s':
            return True
        return False

TEMPLATE_DEBUG=True
TEMPLATE_STRING_IF_INVALID = InvalidVarException()

On pourrait avoir un truc équivalent dans le settings posé pour les tests.

History

#1

Updated by Benjamin Dauvergne over 7 years ago

Ui.

Also available in: Atom PDF