Install django-annoying, which provides some nice shortcuts for common operations

This commit is contained in:
Danielle McLean 2017-10-29 12:41:33 +11:00
parent 88bf1e580c
commit 21786d6e6c
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
5 changed files with 23 additions and 13 deletions

View file

@ -1,10 +1,12 @@
from django.shortcuts import get_object_or_404, render
from annoying.decorators import render_to
from django.shortcuts import get_object_or_404
from users.models import User
from lemoncurry import breadcrumbs, utils
breadcrumbs.add('home:index', 'home')
@render_to('home/index.html')
def index(request):
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
user = get_object_or_404(query, pk=1)
@ -22,10 +24,9 @@ def index(request):
'sameAs': [profile.url for profile in user.profiles.all()]
}
entries = user.entries.all()
return render(request, 'home/index.html', {
return {
'user': user,
'person': person,
'entries': entries,
'entries': user.entries.all(),
'meta': user.as_meta(request),
})
}