diff options
| author | Tiago Honorato <tiagohonorato1@gmail.com> | 2021-03-12 19:37:47 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-03-17 07:49:55 +0100 |
| commit | 4f4f770f77c5d720484c0a71f6a19b9affcc7e28 (patch) | |
| tree | b07f5dba5ec648d7db29040e5604fa9693b7d5dd /django/template/base.py | |
| parent | 065832eaec167a45008aa125887ce1215a1f257d (diff) | |
Refs #24121 -- Added __repr__() to Origin and Template.
Diffstat (limited to 'django/template/base.py')
| -rw-r--r-- | django/template/base.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/template/base.py b/django/template/base.py index b1eec99655..ed1bae3022 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -122,6 +122,9 @@ class Origin: def __str__(self): return self.name + def __repr__(self): + return '<%s name=%r>' % (self.__class__.__qualname__, self.name) + def __eq__(self, other): return ( isinstance(other, Origin) and @@ -158,6 +161,12 @@ class Template: for node in self.nodelist: yield from node + def __repr__(self): + return '<%s template_string="%s...">' % ( + self.__class__.__qualname__, + self.source[:20].replace('\n', ''), + ) + def _render(self, context): return self.nodelist.render(context) |
