from django.http import Http404 from lms.decors import response_decor from library.models import Article @response_decor(template='articles.html', without_auth=True) def article(request, slug): try: a = Article.objects.get(slug=slug) except Article.DoesNotExist: raise Http404 else: a.views_plus(request.user) return {'article': a.get_face(request.user)} @response_decor(template='all_articles.html', without_auth=True) def articles(request): views = 0 for i in Article.objects.filter(public=True): views += i.get_views_length() return {'articles': [article.get_face(request.user) for article in Article.objects.filter(public=True)], 'views': views}