diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2019-11-22 09:40:49 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-22 12:32:30 +0100 |
| commit | 76ec032712d28dd8d4b9ad425f2b330a3e9a9109 (patch) | |
| tree | d805e5e2108dfd8a86beb2f857f389a2854654d2 /django/utils/dateformat.py | |
| parent | 379bf1a2d41494360d86bc3cf8adc482abca5d63 (diff) | |
Refs #26281 -- Added a helpful error message for an invalid "r" specifier to dateformat.format().
Diffstat (limited to 'django/utils/dateformat.py')
| -rw-r--r-- | django/utils/dateformat.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index 578572d38a..5bde2680b8 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -278,6 +278,11 @@ class DateFormat(TimeFormat): def r(self): "RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" + if type(self.data) is datetime.date: + raise TypeError( + "The format for date objects may not contain time-related " + "format specifiers (found 'r')." + ) return self.format('D, j M Y H:i:s O') def S(self): |
