Not found author now returns a 404 error.

This commit is contained in:
Felipe Farias 2017-10-15 20:03:52 -03:00 committed by Iacopo Spalletti
parent c4d1466539
commit c483662885
No known key found for this signature in database
GPG Key ID: BDCBC2EB289F60C6
1 changed files with 2 additions and 1 deletions

View File

@ -16,6 +16,7 @@ from parler.views import TranslatableSlugMixin, ViewUrlMixin
from .models import BlogCategory, Post
from .settings import get_setting
from django.shortcuts import get_object_or_404
User = get_user_model()
@ -166,7 +167,7 @@ class AuthorEntriesView(BaseBlogListView, ListView):
return self.optimize(qs)
def get_context_data(self, **kwargs):
kwargs['author'] = User.objects.get(**{User.USERNAME_FIELD: self.kwargs.get('username')})
kwargs['author'] = get_object_or_404(User, **{User.USERNAME_FIELD: self.kwargs.get('username')})
context = super(AuthorEntriesView, self).get_context_data(**kwargs)
return context