from django.shortcuts import render
from .models import Photos
from django.views.generic import TemplateView


class IndexView(TemplateView):
    template_name = 'index.html'

    def get(self, request, *args, **kwargs):
        context = {
            'photo': Photos.objects.filter(published='public').first()
        }
        return render(request, self.template_name, context=context)

@@ -226,40 +226,11 @@
     
-context = %7B%0A            'photo':
+p =
  Pho
@@ -272,15 +272,72 @@
 c').
-first()
+order_by('?').first()%0A        context = %7B%0A            'photo': p
 %0A   

index selects random photo