#33562 closed New feature (fixed)
set_cookie and set_signed_cookie should accept timedelta object for max_age argument
Reported by: | Luke Plant | Owned by: | Luke Plant |
---|---|---|---|
Component: | HTTP handling | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This already works for get_signed_cookie
:
>>> request.get_signed_cookie("mykey", max_age=timedelta(days=3))
This is due to the underlying behaviour of TimestampSigner
, which was fixed to do this in #21363.
But for set_cookie
and set_signed_cookie
it accepts only a number:
>>> response = HttpResponse() >>> response.set_cookie("mykey", max_age=timedelta(days=3)) TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.timedelta'
Change History (6)
comment:1 by , 3 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 3 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 4.0 → dev |
comment:3 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
PR here - https://github.com/django/django/pull/15481