diff options
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/response.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/http/response.py b/django/http/response.py index 8ae4719575..59120c8e0d 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -227,6 +227,10 @@ class HttpResponseBase: - a naive ``datetime.datetime`` object in UTC, - an aware ``datetime.datetime`` object in any time zone. If it is a ``datetime.datetime`` object then calculate ``max_age``. + + ``max_age`` can be: + - int/float specifying seconds, + - ``datetime.timedelta`` object. """ self.cookies[key] = value if expires is not None: @@ -246,6 +250,8 @@ class HttpResponseBase: else: self.cookies[key]["expires"] = "" if max_age is not None: + if isinstance(max_age, datetime.timedelta): + max_age = max_age.total_seconds() self.cookies[key]["max-age"] = int(max_age) # IE requires expires, so set it if hasn't been already. if not expires: |
