diff --git a/django/core/files/temp.py b/django/core/files/temp.py index 58fbd231dc..77563eed37 100644 --- a/django/core/files/temp.py +++ b/django/core/files/temp.py @@ -69,6 +69,13 @@ if os.name == 'nt': def __del__(self): self.close() + def __enter__(self): + self.file.__enter__() + return self + + def __exit__(self, exc, value, tb): + self.file.__exit__(exc, value, tb) + NamedTemporaryFile = TemporaryFile else: NamedTemporaryFile = tempfile.NamedTemporaryFile