| 12345678910111213141516171819202122 |
- from rest_framework import serializers, status
- from rest_framework.exceptions import ValidationError
- from apps.indicator.models import Indicator
- from apps.indicatortype.models import IndicatorType
- from apps.patient.models import Patient
- class IndicatorSerializer(serializers.ModelSerializer):
- class Meta:
- model = Indicator
- fields = '__all__'
- extra_kwargs = {
- 'observing': {'required': False}
- }
- def create(self, validated_data):
- user = self.context['request'].user
- validated_data['observing'] = user
- indicator = Indicator(**validated_data)
- indicator.save()
- return indicator
|