Last active
November 17, 2019 05:36
-
-
Save aballah-chamakh/ebefaa691af0d9890a094d4c8d8d3280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rest_framework import serializers | |
| from .models import Inference | |
| from .tasks import run_inference | |
| class InferenceSerializers(serializers.ModelSerializers): | |
| class Meta : | |
| model = Inference | |
| fields = ('name','result') | |
| def create(self,validated_data): | |
| name = validated_data.get('name') | |
| image = validated_data.get('image') | |
| inference_obj = Inference.objects.create(name=name,image=image) # or simply Inference.objects.create(**validated_data) | |
| run_infernece.delay(inference_obj.id) # run inference async | |
| return inference_obj | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment