diff options
| author | Marko Benko <marko.benko@gmail.com> | 2016-04-03 19:31:35 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-20 20:13:52 -0400 |
| commit | 45c7acdc507d26451f3c3f22b5d60bdd6d572cfc (patch) | |
| tree | a53bc612d6bcebae325801aca468922914584b76 /django/utils/dateformat.py | |
| parent | b040ac06ebba2348cece7390b88f746d2c91d07b (diff) | |
Fixed #26281 -- Added a helpful error message for an invalid format 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 ea55eaaf9d..f82e0098b8 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -34,6 +34,11 @@ class Formatter(object): pieces = [] for i, piece in enumerate(re_formatchars.split(force_text(formatstr))): if i % 2: + if type(self.data) is datetime.date and hasattr(TimeFormat, piece): + raise TypeError( + "The format for date objects may not contain " + "time-related format specifiers (found '%s')." % piece + ) pieces.append(force_text(getattr(self, piece)())) elif piece: pieces.append(re_escaped.sub(r'\1', piece)) |
