python - How to insert POST data into Django model using rest-frameWork -


i trying post data django app using django rest-framework...

my view :

@csrf_view_exempt class subscriptionslist(apiview):      def post(self, request, format=none):         key = self.request.query_params.get('appkey', none)         keydata = app.objects.filter(appkey=key).exists()                   if keydata == true:             serializer = postsubscriptiondetailserializer(data=request.data)             if serializer.is_valid():                 serializer.save()                 return response(serializer.data, status=status.http_201_created)             return response(serializer.errors, status=status.http_400_bad_request) 

urls.py : url(r'^subscribe/$',subscriptionslist,name='subscriptions-list'),

serializer.py

class postsubscriptiondetailserializer(serializers.modelserializer):     class meta:         model = subscriptions         fields = ('subappname','substorename','subtagname','emailid') 

can tell me how post data using django rest-framework...


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -