Rest Framework Seralizer始终从is_valid返回false

时间:2019-06-01 19:27:58

标签: django python-3.x django-rest-framework

我正在建立一个汽车存货数据库,并试图用api提供的json数据填充它。我的Seralizer有什么问题?

这是Windows,Django2和Sqlite数据库 Python3

  

seralizer.py

```from rest_framework import serializers
from .models import SavedInventory

class EmbedSerializer(serializers.ModelSerializer):
    class Meta:
        model = SavedInventory
        fields = '__all__'
```
views.py 
``` 
vin = form.cleaned_data['vin']
            links={"X-RapidAPI-Host":settings.VINDECODERHOST, "X-RapidAPI-Key": settings.VINDECODERKEY}
            r = requests.get("https://vindecoder.p.rapidapi.com/decode_vin?vin="+ vin + "&key=" + settings.VINDECODERKEY)
            json = r.json()
            serializer = EmbedSerializer(data=json)
            if serializer.is_valid():
                saved = serializer.save()
                return render(request, 'saved.html', {'embed': embed})
            else:
                return HttpResponse('<h1>ERROR Seralizer</h1>')



0 个答案:

没有答案