... ls. このチュートリアルでは、地理情報を表示するためのウェブアプリケーションの作成方法を説明します。このチュートリアルでは、 world borders [ 1 ] を表示します。このチュートリアルで使用されるコードの一部は、 GeoDjango basic apps プロジェクトから取得された ... ...\> django-admin startproject geodjango これで新しいプロジェクトが初期化されます。ここで、 geodjango プロジェクトの中に world Django アプリケーションを作成します: / $ cd geodjango $ python manage.py startapp world ...\> cd geodjango ...\> py ma ... nage.py startapp world settings.py の設定 geodjango プロジェクトの設定は geodjango/settings.py ファイルに保存されています。データベース接続設定を ... ... ります。 ペースの速いニュースルームでは、World Onlineが、複雑なWebアプリケーションをコンセプトから公開するまでにほんの数時間しかかからないことがよくあります。 しかし同時 ... に、WorldOnline の Web 開発者たちは、特に Web 開発のベストプラクティスに従うことに関しては、一貫して完璧主義者でした。 2003年の秋、W ... トのコードから汎用の Web 開発フレー ムワークを切り出し、 2 年近くの間ずっと改良を加えながら使い込んできました。 2005年の夏、World Online は、これまでの開発の成果を Django としてオープンソース化する決定を下しました。Django は Apache , Python , そして Po ... ... ることです: >>> from django.core.files import File # Create a Python file object using open() >>> f = open ( "/path/to/hello.world" , "w" ) >>> myfile = File ( f ) これで、 File クラスのドキュメント化された属性とメソッドのすべてを使えるようになりました。 ... o.core.files import 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 T ... ... " , "source_lines" : [ ( 1 , "some \n " ), ( 2 , "lines \n " ), ( 3 , "before \n " ), ( 4 , "Hello { % s yntax error %} {{ world }} \n " ), ( 5 , "some \n " ), ( 6 , "lines \n " ), ( 7 , "after \n " ), ( 8 , "" ), ], "line" : 4 , "before" : "Hello " , ... "during" : "{ % s yntax error %}" , "after" : " {{ world }} \n " , "total" : 9 , "bottom" : 9 , "top" : 1 , } Origin API と サードパーティとの統合 Djangoテンプレートでは、 templat ... ... トとして振る舞い、Django の FileResponse オブジェクトがファイルライクなオブジェクトを受け取るということです。 ここに、"Hello World"の例を示します: import io from django.http import FileResponse from reportlab.pdfgen import canvas def some_view ( request ... eration happens. # See the ReportLab documentation for the full list of functionality. p . drawString ( 100 , 100 , "Hello world." ) # Close the PDF object cleanly, and we're done. p . showPage () p . save () # FileResponse sets the Content-Dispositio ... ... 。 element_id パラメータが None でない場合、 <script> タグに渡されたidが与えられます。例えば: >>> json_script ({ "hello" : "world" }, element_id = "hello-data" ) '<script id="hello-data" type="application/json">{"hello": "world"}</script>' encoder のデ ... ) を使用するべきです。 マークされた文字列を安全としても、変更されると再び安全でなくなります。例えば: >>> mystr = "<b>Hello World</b> " >>> mystr = mark_safe ( mystr ) >>> type ( mystr ) <class 'django.utils.safestring.SafeString'> >>> mystr = mystr . ... is a slug " ) 'joel-is-a-slug' Unicode 文字を許可したい場合は、 allow_unicode=True を渡します。例えば: >>> slugify ( "你好 World" , allow_unicode = True ) '你好-world' django.utils.timezone get_fixed_timezone ( offset ) [ソース] UTCからの固定オフセット ... ... ドを書いてください: polls/views.py from django.http import HttpResponse def index ( request ): return HttpResponse ( "Hello, world. You're at the polls index." ) これはDjangoにおける最も基本的なビューです。これにブラウザからアクセスするためには、URLにマ ... ython manage.py runserver ...\> py manage.py runserver ブラウザで http://localhost:8000/polls/ にアクセスすると、 " Hello, world. You're at the polls index. " と表示されるのが確認できるでしょう。これはビューの index で定義したものです。 ページが見つか ... ... うになります。 cache. set ( key , value , timeout = DEFAULT_TIMEOUT , version = None ) >>> cache . set ( "my_key" , "hello, world!" , 30 ) cache. get ( key , default = None , version = None ) >>> cache . get ( "my_key" ) 'hello, world!' key には str を ... のキャッシュキーのバージョンを指定できます。たとえば: >>> # Set version 2 of a cache key >>> cache . set ( "my_key" , "hello world!" , version = 2 ) >>> # Get the default version (assuming version=1) >>> cache . get ( "my_key" ) None >>> # Get version 2 ... of the same key >>> cache . get ( "my_key" , version = 2 ) 'hello world!' 特定のキーのバージョンは incr_version() メソッドと decr_version() メソッドで増減できます。これにより、特定のキーのバージ ... ... C, there's a #django channel on irc.libera.chat that is regularly populated by Django users and developers from around the world. Friendly people are usually available at any hour of the day -- to help, or just to chat. Thanks for using Django! The Dj ... ... tentFile class MyCommand ( BaseCommand ): def handle ( self , * args , ** options ): content_file = ContentFile ( b "Hello world!" , name = "hello-world.txt" ) instance = ModelWithFileField ( file_field = content_file ) instance . save () 複数のファイ ... 2026年10月08日