Permalink
Browse files

Test for date attribute before using it.

I was getting the following error:  
`CRITICAL: AttributeError: 'Page' object has no attribute 'date'`
I tested with my site and it seemed to work.
  • Loading branch information...
mandaris committed Mar 1, 2018
1 parent 8b5862d commit 61248d805588245a9fc1dc4eda56cff1f5a9d8fa
Showing with 3 additions and 2 deletions.
  1. +3 −2 open_graph.py
View
@@ -82,8 +82,9 @@ def open_graph_tag(item):
ogtags.append(('og:site_name', item.settings.get('SITENAME', '')))
ogtags.append(('article:published_time',
strftime(item.date, "%Y-%m-%d")))
if hasattr(item, date):

This comment has been minimized.

@alexiosc

alexiosc Mar 4, 2018

Isn't this missing the quotes? e.g. if hasattr(item, "date"):

This comment has been minimized.

@patrickfournier

patrickfournier Mar 6, 2018

Contributor

yes...

This comment has been minimized.

@patrickfournier

patrickfournier Mar 6, 2018

Contributor

I commited the fix

ogtags.append(('article:published_time',
strftime(item.date, "%Y-%m-%d")))
if hasattr(item, 'modified'):
ogtags.append(('article:modified_time', strftime(

0 comments on commit 61248d8

Please sign in to comment.