mirror of
https://github.com/leaders-of-digital-9-task/backend.git
synced 2024-11-15 05:56:34 +03:00
25 lines
660 B
Python
25 lines
660 B
Python
from dicom.models import Dicom
|
|
from rest_framework import serializers
|
|
|
|
|
|
class ListDicomSerializer(serializers.ModelSerializer):
|
|
url = serializers.HyperlinkedIdentityField(
|
|
view_name="get_update_delete_dicom", lookup_field="slug"
|
|
)
|
|
file = serializers.FileField()
|
|
|
|
class Meta:
|
|
model = Dicom
|
|
fields = ["file", "uploaded", "url"]
|
|
|
|
def create(self, validated_data):
|
|
return Dicom.objects.create(**validated_data, user=self.context["request"].user)
|
|
|
|
|
|
class DicomSerializer(serializers.ModelSerializer):
|
|
file = serializers.FileField()
|
|
|
|
class Meta:
|
|
model = Dicom
|
|
fields = ["file", "uploaded"]
|