def fortunes(request): fortunes = list(Fortune.objects.all()) fortunes.append(Fortune(id=0, message="Additional fortune added at request time.")) fortunes = sorted(fortunes, key=attrgetter("message")) context = {"fortunes": fortunes} return render(request, "fortunes.html", context)
def fortunes(request): fortunes = list(Fortune.objects.all()) fortunes.append( Fortune(id=0, message="Additional message added at runtime.")) fortunes = sorted(fortunes, key=attrgetter('message')) context = {'fortunes': fortunes} return render(request, 'fortunes.html', context)