Re: getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread zohaib younis
arbaz bro i am still getting the same error On Mon, Apr 8, 2019 at 3:10 PM zohaib younis wrote: > from rest_framework import serializers > from .models import EvaluationTest, Question, Choice, > GradeEvaluationText, Category > from users.models import User > > > class StringSerializer(serializer

Re: getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread zohaib younis
from rest_framework import serializers from .models import EvaluationTest, Question, Choice, GradeEvaluationText, Category from users.models import User class StringSerializer(serializers.StringRelatedField): def to_internal_value(self, value): return value class ChoiceSerializer(serializers.Mo

Re: getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread Arbaz Hundekar
try this questions = self.context['request'].data.get("questions",None) If questions is not in request.data it will be set to None. It will work with your not condition as well. On Mon, Apr 8, 2019 at 6:35 PM zohaib younis wrote: > arbaz thanks for your guidance i have resolved that issue now w

Combine DRF existing translations with project translations

2019-04-08 Thread Bert Lievrouw
Django rest framework comes with plenty of translations for error messages, ... However, when I want to combine these my own project's translations it stops working. I described the problem i ran into here . I then grudgingly tried co

Re: getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread zohaib younis
arbaz thanks for your guidance i have resolved that issue now when i try to create a test it is giving me an error for question in data["questions"]: keyError :'questions' can you help me with that problem thanks On Mon, Apr 8, 2019 at 3:00 PM Arbaz Hundekar < arbaz.hunde...@avetoconsulting.com> w

Re: getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread Arbaz Hundekar
while instantiating your serializer do like this ser = Serializer(context={"request": request}) On Mon, Apr 8, 2019 at 1:57 PM zohaib younis wrote: > def validate(self, data, *args, **kwargs): > questions = self.context['request'].data.get("questions") > if not questions: > raise serializers.Val

getting keyError: 'request' i am getting this error when i am to create an evaluation test i am newbie to django rest framework can somebody help me why i am getting this error

2019-04-08 Thread zohaib younis
def validate(self, data, *args, **kwargs): questions = self.context['request'].data.get("questions") if not questions: raise serializers.ValidationError("questions are required") if self.context["request"].method == "POST": self.questions = QuestionSerializer(data=questions, many=True) self.questio