生成价值>在Django REST Framework上保存并返回生成的值

时间:2014-04-27 04:36:12

标签: python django django-rest-framework

我有以下代码,它只能工作一半。我想要做的是

在数据库上保存(studentID,tutorID,sessionID)。

伪代码

GENREATE SESSION_ID

SAVE (SESSION_ID, STUDENTID, TUTORID)

RETURN SESSION_ID AS RESPONSE

Views.py

@api_view(['GET', 'POST'])
def startCall(request, studentID, tutorID):

if request.method == 'POST':

    API_KEY = 'APIKEY'
    API_SECRET = 'API_SECRET'
    OTSDK = OpenTokSDK.OpenTokSDK(API_KEY,API_SECRET)
    session_id = OTSDK.create_session().session_id

    response = {}
    response['session_id'] = str(session_id)
    return Response(response)

serializers.py

class startCallSerializer(serializers.ModelSerializer):

class Meta:
    model = call
    fields = ('tutor', 'billed', 'billed_status',
              'tutor_status', 'sid', 'started', 'finished')

0 个答案:

没有答案