get data about XBlocks with Django REST framweork

10 views
Skip to first unread message

chemseddine zaafrane

unread,
Apr 4, 2017, 6:53:15 AM4/4/17
to General Open edX discussion
I created a new model inside xblock-sdk/models.py file called scenarios with multiple fields and then serialized them so i can access them using django rest framwork,

#models.py
class Scenarios(models.Model):
    description
= models.TextField()
   
XBlock_id = models.CharField(max_length=100)

   
def __repr__(self):
       
return u"<description={self.scenario} " \
           
"XBlock_id={self.scenario_id}>".format(self=self)

#serializer.py
class xblockSerializer(serializers.ModelSerializer):
   
class Meta:
        model
= Scenarios
        fields
= '__all__'

the purpose is to get all the  data about the available xblocks. however when i access the url in django rest framework i find an empty response which seems to be logic because i only created a model and i didn't populate it with the available xblocks data.

my question is what should i do in order to get a response with the data about the xblocks.
Reply all
Reply to author
Forward
0 new messages