>>> from core.viewsets import *
>>> a = [{u'id': 278, u'text': u'552'},
... {u'id': 287, u'text': u'in, on, in, At;'},
... {u'id': 352, u'text': u'pH = 2,0'}]
>>> s = QuestionOptionSerializer(data=a, many=True)
>>> s.is_valid()
True
>>> s.data
[OrderedDict([('text', u'552')]), OrderedDict([('text', u'in, on, in, At;')]), OrderedDict([('text', u'pH = 2,0')])]
QuestionOptionSerializer is defined like this:
class QuestionOptionSerializer(serializers.ModelSerializer):
class Meta:
model = QuestionOption
exclude = ('is_correct',)
And the model, like this:
class QuestionOption(models.Model):
text = models.TextField()
is_correct = models.BooleanField(default=False)
objects = MasterQuerySetManager()
class QuerySet(MasterQuerySet):
def correct(self):
return self.filter(is_correct=True)
def incorrect(self):
return self.filter(is_correct=False)
class Meta():
db_table = 'question_option'
def __unicode__(self):
return self.text[:50]
What method should I call to get back a queryset?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
| Filipe Ximenes +55 (81) 8245-9204 Vinta Software Studio http://www.vinta.com.br |
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.