Marcolac
Marcolac

Reputation: 931

Django date format in template : %B causes "No exception message supplied" error

I'm trying to format a datetime in a template with Django, and I have a strange problem.

I have a simple loop :

<tbody>
       {% for event in events %}
       <tr>                                     
          <td>
              <strong>Le {{event.start}}</strong>                                          
          </td>
       </tr>
       {% endfor %}
</tbody>

It works great, the date looks like that : "Le 9 janvier 2015 10:00:00"

If I use {{event.start|date:"d b Y"}} it still works. I have a date like :"Le 09 jan 2015"

BUT, if I use {{event.start|date:"d B Y"}}, in order to have the Month as locale’s full name (see docs) I get this error :

NotImplementedError at /annuler-rendez-vous/
No exception message supplied

And I have absolutely no idea why I get this problem only when I use "B".

Any help would be very much appreciated ! Thanks !

Upvotes: 2

Views: 741

Answers (1)

castledom04
castledom04

Reputation: 217

The "B" format is not implemented. You can use the format "F" which does exactly the same. I found it looking at the code: https://github.com/django/django/blob/master/django/utils/dateformat.py#L225

Your code will look like this:

{{event.start|date:"d F Y"}}

Upvotes: 2

Related Questions