Hi,
There is no error. But based on the urls settings I could see the "QuizList" 
output to my web page. Other than that, other serializers are not being 
displayed there. Below is the serializers.py 
from rest_framework import serializers
from .models import Quiz, Question, QuizTakers, Answer, User
from django.contrib.auth import authenticate, login


class userSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = 'email'


class QuizSerializer(serializers.ModelSerializer):
    class Meta:
        model = Quiz()
        fields = ('name', 'questions_count', 'description', 'created', 
'roll_out')

    def createQuestion(self, validated_data):
        return Question().objects.create_question(**validated_data)


class AnswerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Answer()
        fields = ('question', 'text', 'is_correct')


class QuestionSerializer(serializers.ModelSerializer):

    class Meta:
        model = Question()
        fields = ('quiz', 'label', 'order')


class QuizTakerSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = QuizTakers()
        fields = ('user', 'quiz', 'correct_answers', 'completed', 'timestamp')



Regards,
Amitesh 

    On Thursday, 5 December, 2019, 12:19:34 am IST, Integr@te System 
<datacentral...@gmail.com> wrote:  
 
 Hi Issuer, Plz show result with errors.
Tks.
On Thu, Dec 5, 2019, 01:31 'Amitesh Sahay' via Django users 
<django-users@googlegroups.com> wrote:

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


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1895937763.9174288.1575484276499%40mail.yahoo.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWo1YnZf9Y0cOUYtYc-noQTzVz%3Do90k9Fy37SD%2BPcqQ75Q%40mail.gmail.com.
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2093858531.9194413.1575486878110%40mail.yahoo.com.

Reply via email to