from django.shortcuts import render

# Create your views here.
from django.core import serializers
from django.http import HttpResponse
from django.http import JsonResponse
from .models import DailyQuote
from .models import Quote
from django.utils import timezone

def index(request):
    return HttpResponse("Hello, world. You're at the quotes index.")

def daily_quote(request):
	latest_daily_quote = DailyQuote.objects.all().order_by('-id')[:1]
	if(latest_daily_quote[0].date_used.date() >= timezone.now().date()):
		todays_quote = latest_daily_quote[0].to_dict()
	else:
		todays_quote = {}
	todays_quote = latest_daily_quote[0].to_dict()
	return JsonResponse(todays_quote)
@@ -440,16 +440,19 @@
 id')%5B:1%5D
+%5B0%5D
 %0A%09if(lat
@@ -466,19 +466,16 @@
 ly_quote
-%5B0%5D
 .date_us
@@ -546,29 +546,16 @@
 ly_quote
-%5B0%5D.to_dict()
 %0A%09else:%0A
@@ -575,27 +575,30 @@
 e = 
-%7B%7D%0A%09todays_quote = 
+DailyQuote.get_random(
 late
@@ -615,20 +615,11 @@
 uote
-%5B0%5D.to_dict(
+.pk
 )%0A%09r
@@ -649,9 +649,19 @@
 ys_quote
+.to_dict()
 )

refactor to return a random daily_quote if the current one is stale