I am in the process of developing a small project using django rest framework, and within that requirement, I need to list every table in one single page. Below is the code snippet.
class QuizList(APIView): renderer_classes = [TemplateHTMLRenderer] template_name = 'adminView.html' def get(self, request): queryset = Quiz.objects.all() return Response({'quiz': queryset}) class AnswerList(APIView): renderer_classes = [TemplateHTMLRenderer] template_name = 'adminView.html' def get(self, request): queryset = Answer.objects.all() return Response({'answer': queryset}) class QuestionList(APIView): renderer_classes = [TemplateHTMLRenderer] template_name = 'adminView.html' def get(self, request): queryset = Question.objects.all() return Response({'question': queryset})In the above snippet, I am able to list the very first class "QuizView" on my web page. But other than that, when I am trying to add other APIViews, they are simply not happening. Below is the HTML template:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Admin View</title> </head> <body> <ul> {% for quizez in quiz %} <a href="" onclick="">{{ quizez.name }}</a> {% endfor %} </ul> <ul> {% for questions in question %} <li>{{ questions.label }}</li> {% endfor %} </ul> <ul> {% for answers in answer %} <li>{{ answer.text }}</li> {% endfor %} </ul> </body> </html>I tried to put all the for loops within a single "ul", but even that didn't work. Please help.
Thank you
No comments:
Post a Comment