              return get_attribute(instance, self.source_attrs)
          except (KeyError, AttributeError) as exc:
              if self.default is not empty:
                  return self.get_default()
              if not self.required:
                  raise SkipField()
              if self.allow_null:
                  return None
              msg = (
                  'Got {exc_type} when attempting to get a value for field '
                  '`{field}` on serializer `{serializer}`.\nThe serializer '
 
</s> remove     def test_not_required_output_for_allow_null_field(self):
        class ExampleSerializer(serializers.Serializer):
            omitted = serializers.CharField(required=False, allow_null=True)
            included = serializers.CharField()

        serializer = ExampleSerializer({'included': 'abc'})
        assert 'omitted' not in serializer.data

 </s> add  </s> remove         # allow_null=True should imply default=None
 </s> add         """
        Without an explicit default, allow_null implies default=None when serializing. #5518 #5708
        """
              return get_attribute(instance, self.source_attrs)
          except (KeyError, AttributeError) as exc:
              if self.default is not empty:
                  return self.get_default()


              if self.allow_null:
                  return None
              msg = (
                  'Got {exc_type} when attempting to get a value for field '
                  '`{field}` on serializer `{serializer}`.\nThe serializer '
keep keep keep keep replace replace keep keep keep keep keep
 Correct allow_null behaviour when required=False (#5888)

* Revert "Non-required fields with 'allow_null=True' should not imply a default value (#5639)"
    This reverts commit 905a5579dfaa717ad4210ddd285267bb9bbb9a43.
    Closes #5708

* Add test for allow_null + required=False
    Ref #5708: allow_null should imply default=None, even for non-required fields.

* Re-order allow_null and default in field docs
    default is prior to allow_null. allow_null implies an outgoing default=None.

* Adjust allow_null note. 
rest_framework/fields.py