add time to datePublished
This commit is contained in:
parent
c123e74c1f
commit
4bc6e7d354
1 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,9 @@
|
|||
# hub/services/templatetags/json_ld_tags.py
|
||||
from datetime import datetime, time
|
||||
from django import template
|
||||
from django.urls import resolve, Resolver404
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils import timezone as django_timezone
|
||||
|
||||
import json
|
||||
|
||||
register = template.Library()
|
||||
|
@ -332,8 +334,10 @@ def json_ld_structured_data(context):
|
|||
}
|
||||
|
||||
# Add publication date using article_date field
|
||||
if article.article_date:
|
||||
data["datePublished"] = article.article_date.isoformat()
|
||||
article_datetime = django_timezone.make_aware(
|
||||
datetime.combine(article.article_date, time.min)
|
||||
)
|
||||
data["datePublished"] = article_datetime.isoformat()
|
||||
|
||||
# Add modification date
|
||||
if article.updated_at:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue