... of these model fields has changed. You will need to make the following changes, assuming your model's FileField is called myfile : Old (0.96) New (1.0) myfile.get_content_filename() myfile.content.path myfile.get_content_url() myfile.content.url myfil ... e.get_content_size() myfile.content.size myfile.save_content_file() myfile.content.save() myfile.get_content_width() myfile.content.width myfile.get_c ... ontent_height() myfile.content.height Note that the width and height attributes only make sense for ImageField fields. More details can be found ... ... django.core.files import File # Create a Python file object using open() >>> f = open ( "/path/to/hello.world" , "w" ) >>> myfile = File ( f ) これで、 File クラスのドキュメント化された属性とメソッドのすべてを使えるようになりました。 この方法で作成され ... Create a Python file object using open() and the with statement >>> with open ( "/path/to/hello.world" , "w" ) as f : ... myfile = File ( f ) ... myfile . write ( "Hello World" ) ... >>> myfile . closed True >>> f . closed True ファイルを閉じることは、 ... ... m django.core.files import File # Open an existing file using Python's built-in open() f = open ( "/path/to/hello.world" ) myfile = File ( f ) もしくは、以下のように Python の文字列から構築することもできます: from django.core.files.base import ContentF ... ile myfile = ContentFile ( "hello world" ) より詳しくは ファイルの管理 を参照してください。 FieldFile. delete ( save = True ) [ソース ... ... るファイルライクオブジェクトを受け付けます。 >>> from django.http import FileResponse >>> response = FileResponse ( open ( "myfile.png" , "rb" )) ファイルは自動的に閉じられるため、コンテキストマネージャーで開かないでください。 ASGI における使用 Pythonの ... 2026年10月08日