... 、その特定の設定ファイルに関連付けられている Site オブジェクトのデータベース ID を指定します。この設定が省略された場合、 get_current_site() 関数は、 domain と request.get_host() メソッドからのホスト名を比較することで、現在のサイトを取得しようとします。 こ ... トーリーが 現在のサイトにあるかどうかをチェックします。以下のようになります: from django.contrib.sites.shortcuts import get_current_site def article_detail ( request , article_id ): try : a = Article . objects . get ( id = article_id , sites__id = get_cu ... e to hardcode the site IDs like that, in case they change. The cleaner way of accomplishing the same thing is to check the current site's domain: from django.contrib.sites.shortcuts import get_current_site def my_view ( request ): current_site = get_cur ... ... 、その特定の設定ファイルに関連付けられている Site オブジェクトのデータベース ID を指定します。この設定が省略された場合、 get_current_site() 関数は、 domain と request.get_host() メソッドからのホスト名を比較することで、現在のサイトを取得しようとします。 こ ... トーリーが 現在のサイトにあるかどうかをチェックします。以下のようになります: from django.contrib.sites.shortcuts import get_current_site def article_detail ( request , article_id ): try : a = Article . objects . get ( id = article_id , sites__id = get_cu ... e to hardcode the site IDs like that, in case they change. The cleaner way of accomplishing the same thing is to check the current site's domain: from django.contrib.sites.shortcuts import get_current_site def my_view ( request ): current_site = get_cur ... ... グは、文字列やテンプレート変数などの引数を取り、入力引数と外部情報のみに基づいて処理を行った後、結果を返します。 たとえば、 current_time タグはフォーマット文字列を受け取り、その時刻を適切な文字列フォーマットとして返します。 これらのタイプのタグの作成を容 ... 関数を取り、それを render 関数と上記で説明した他の必要なビットにラップし、そしてテンプレートシステムに登録します。 私たちの current_time 関数は、以下のように書くことができます: import datetime from django import template register = template . Library () ... @register . simple_tag def current_time ( format_string ): return datetime . datetime . now () . strftime ( format_string ) simple_tag ヘルパー関数について、 ... ... グは、文字列やテンプレート変数などの引数を取り、入力引数と外部情報のみに基づいて処理を行った後、結果を返します。 たとえば、 current_time タグはフォーマット文字列を受け取り、その時刻を適切な文字列フォーマットとして返します。 これらのタイプのタグの作成を容 ... 関数を取り、それを render 関数と上記で説明した他の必要なビットにラップし、そしてテンプレートシステムに登録します。 私たちの current_time 関数は、以下のように書くことができます: import datetime from django import template register = template . Library () ... @register . simple_tag def current_time ( format_string ): return datetime . datetime . now () . strftime ( format_string ) simple_tag ヘルパー関数について、 ... ... QueryLogger : def __init__ ( self ): self . queries = [] def __call__ ( self , execute , sql , params , many , context ): current_query = { "sql" : sql , "params" : params , "many" : many } start = time . monotonic () try : result = execute ( sql , par ... ams , many , context ) except Exception as e : current_query [ "status" ] = "error" current_query [ "exception" ] = e raise else : current_query [ "status" ] = "ok" return resul ... t finally : duration = time . monotonic () - start current_query [ "duration" ] = duration self . queries . append ( current_query ) これを使用するには、ロガーオブジェクトを作成し、 ... ... QueryLogger : def __init__ ( self ): self . queries = [] def __call__ ( self , execute , sql , params , many , context ): current_query = { "sql" : sql , "params" : params , "many" : many } start = time . monotonic () try : result = execute ( sql , par ... ams , many , context ) except Exception as e : current_query [ "status" ] = "error" current_query [ "exception" ] = e raise else : current_query [ "status" ] = "ok" return resul ... t finally : duration = time . monotonic () - start current_query [ "duration" ] = duration self . queries . append ( current_query ) これを使用するには、ロガーオブジェクトを作成し、 ... ... とができるようになりました。詳しくは データベースを使ったセッションを拡張する を読んでください。 django.contrib.sites ¶ get_current_site() が新たに request.get_host() が domain:port という形式 (例: example.com:80 ) の値を返す場合でもハンドリングできるよう ... only the date portion. Added the Greatest and Least database functions. Added the Now database function, which returns the current date and time. Transform is now a subclass of Func() which allows Transform s to be used on the right hand side of an expr ... and bulk_create() . Request と Response ¶ Unless HttpResponse.reason_phrase is explicitly set, it now is determined by the current value of HttpResponse.status_code . Modifying the value of status_code outside of the constructor will also modify the val ... ... とができるようになりました。詳しくは データベースを使ったセッションを拡張する を読んでください。 django.contrib.sites ¶ get_current_site() が新たに request.get_host() が domain:port という形式 (例: example.com:80 ) の値を返す場合でもハンドリングできるよう ... only the date portion. Added the Greatest and Least database functions. Added the Now database function, which returns the current date and time. Transform is now a subclass of Func() which allows Transform s to be used on the right hand side of an expr ... and bulk_create() . Request と Response ¶ Unless HttpResponse.reason_phrase is explicitly set, it now is determined by the current value of HttpResponse.status_code . Modifying the value of status_code outside of the constructor will also modify the val ... ... contained non-ASCII characters ( #21627 ). The collectstatic command will raise an error rather than default to using the current working directory if STATIC_ROOT is not set. Combined with the --clear option, the previous behavior could wipe anything b ... elow the current working directory ( #21581 ). Fixed mail encoding on Python 3.3.3+ ( #21093 ). Fixed an issue where when settings.DATABASE ... リリースノート 次のトピックへ Django 1.6.1 リリースノート 関連キーワード Fixed issue release geometry crash command default current working directory inheritance utils safe リリースノート February bugfix fixes several bugs Prevented base prepared garbage ... ... contained non-ASCII characters ( #21627 ). The collectstatic command will raise an error rather than default to using the current working directory if STATIC_ROOT is not set. Combined with the --clear option, the previous behavior could wipe anything b ... elow the current working directory ( #21581 ). Fixed mail encoding on Python 3.3.3+ ( #21093 ). Fixed an issue where when settings.DATABASE ... 次のトピックへ Django 1.6.1 リリースノート 関連キーワード Django Fixed issue release geometry object crash command default current working directory inheritance django utils safe six リリースノート February bugfix 関連するページ Django 1.8.7 リリースノー ... 2026年10月08日