This commit is contained in:
Ross
2021-09-25 21:16:53 +01:00
parent 48af075a14
commit 85379eb128
5 changed files with 39 additions and 21 deletions
+21 -1
View File
@@ -1,3 +1,4 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.forms.models import model_to_dict
from django.shortcuts import render, get_object_or_404, redirect
@@ -738,4 +739,23 @@ class GenericViewBase:
request,
f"{self.app_name}/question_user_answers.html",
{"question": question, "answers": answers},
)
)
@method_decorator(login_required)
def author_detail(self, request, pk):
# logging.debug(Author.objects.all())
# author = get_object_or_404(Author, pk=pk)
author = User.objects.get(pk=pk)
questions = self.question_object.objects.filter(author=pk)
return render(
request, f"{self.app_name}/category_detail.html", {"category": author, "questions": questions}
)
@method_decorator(login_required)
def author_list(self, request):
authors = User.objects.all()
return render(request, f"{self.app_name}/author_list.html", {"authors": authors})