          # This returns a different result each time,
          # to make sure it only gets called once.
          return '%s/%s' % (random.randint(100, 999), filename)
  
      normal = models.FileField(storage=temp_storage, upload_to='tests')
      custom = models.FileField(storage=temp_storage, upload_to=custom_upload_to)
      pathlib_callable = models.FileField(storage=temp_storage, upload_to=pathlib_upload_to)
      random = models.FileField(storage=temp_storage, upload_to=random_upload_to)
 
</s>
    def pathlib_upload_to(self, filename):
        return Path('bar') / filename

          # This returns a different result each time,
          # to make sure it only gets called once.
          return '%s/%s' % (random.randint(100, 999), filename)
  
    def pathlib_upload_to(self, filename):
        return Path('bar') / filename

      normal = models.FileField(storage=temp_storage, upload_to='tests')
      custom = models.FileField(storage=temp_storage, upload_to=custom_upload_to)
      pathlib_callable = models.FileField(storage=temp_storage, upload_to=pathlib_upload_to)
      random = models.FileField(storage=temp_storage, upload_to=random_upload_to)
keep keep keep add keep keep keep keep
 Refs #28428 -- Added test for a callable FileField.upload_to that returns pathlib.Path.
tests/file_storage/models.py