Private
Public Access
1
0

adding command to store blog posts locally

This commit is contained in:
Sander Roosendaal
2019-10-17 22:09:01 +02:00
parent ed02c7c52b
commit 45666d22a7
3 changed files with 70 additions and 2 deletions

View File

@@ -103,7 +103,7 @@ from rowers.models import (
Team,TeamForm,TeamInviteForm,TeamInvite,TeamRequest,
WorkoutComment,WorkoutCommentForm,RowerExportForm,
CalcAgePerformance,
PowerTimeFitnessMetric,
PowerTimeFitnessMetric,BlogPost,
PlannedSessionForm,
PlannedSessionFormSmall,GeoCourseEditForm,VirtualRace,
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
@@ -801,8 +801,23 @@ def get_thumbnails(request,id):
return JSONResponse(charts)
def get_blog_posts(request):
blogposts = BlogPost.objects.all().order_by("-date")
jsondata = []
if blogposts:
for blogpost in blogposts[0:3]:
thedict = {
'title':blogpost.title,
'link':blogpost.link,
}
jsondata.append(thedict)
return JSONResponse(jsondata)
def get_blog_posts_old(request):
try:
response = requests.get(
'https://analytics.rowsandall.com/wp-json/wp/v2/posts?per_page=3')