reservations/validators.py
def enforce_required_fields(self, attrs, serializer):
        """Require datetime ranges and room fields to be set."""
        if serializer.instance is not None:
            return

        missing_items = {
            field_name: _("This field is required.")
            for field_name in self.required_fields
            if serializer.fields[field_name].source not in attrs
        }
        if missing_items:
            raise serializers.ValidationError(missing_items, code="required")
Require datetime ranges and room fields to be set.
Require datetime ranges and room fields to be set.
Require datetime ranges and room fields to be set .
def enforce_required_fields(self, attrs, serializer):
        if serializer.instance is not None:
            return
        missing_items = {
            field_name: _("This field is required.")
            for field_name in self.required_fields
            if serializer.fields[field_name].source not in attrs
        }
        if missing_items:
            raise serializers.ValidationError(missing_items, code="required")
def enforce_required_fields ( self , attrs , serializer ) : if serializer . instance is not None : return missing_items = { field_name : _ ( "This field is required." ) for field_name in self . required_fields if serializer . fields [ field_name ] . source not in attrs } if missing_items : raise serializers . ValidationError ( missing_items , code = "required" )
Require datetime ranges and room fields to be set.
Require datetime ranges and room fields to be set .
"""Require datetime ranges and room fields to be set."""
self
attrs
serializer