per page, with , order by , clip by
Results of 1 - 10 of about 50 for except (0.008 sec.)
テンプレートのバックエンドをカスタマイズする 12648
テンプレートのバックエンドをカスタマイズする カスタムのバックエンド ここでは、他のテンプレートシステムを使用するために、カスタムテンプレートバックエンドを実装する方法を説明します。テンプレートバックエンドは django.template.backends.base.Bas ... options ) def from_string ( self , template_code ): try : return Template ( self . engine . from_string ( template_code )) except foobar . TemplateCompilationFailed as exc : raise TemplateSyntaxError ( exc . args ) def get_template ( self , template_na ... me ): try : return Template ( self . engine . get_template ( template_name )) except foobar . TemplateNotFound as exc : raise TemplateDoesNotExist ( exc . args , backend = self ) except foobar . TemplateComp ...
https://man.mtool.work/django/6.1/howto/custom-template-backend.html
データベースのトランザクション 11460
データベースのトランザクション Django では、データベースのトランザクションをコントロールする方法が提供されています。 データベースのトランザクションを管理する Django のデフォルトのトランザクションの動作 Django のデフォルトの動作は、オートコミ ... ango's default). do_stuff () with transaction . atomic (): # This code executes inside a transaction. do_more_stuff () try/except ブロック内で atomic をラップすると、integrity error を自然な形で処理できます: from django.db import IntegrityError , trans ... nsaction . atomic def viewfunc ( request ): create_parent () try : with transaction . atomic (): generate_relationships () except IntegrityError : handle_exception () add_children () この例では、 generate_relationships() が整合性制約を破ってデータベース ... create_parent() での変更はそのまま同じトランザクションにバインドされます。 generate_relationships() 内での試行は、 handle_exception() が呼び出された時点ですでに安全にロールバックされていることに留意してください。したがって、必要に応じてデータベース上で ...
https://man.mtool.work/django/6.1/topics/db/transactions.html
Coding style 11054
Coding style Please follow these coding standards when writing code for inclusion in Django. Pre-commit checks pre-commit is a framework for managing pre-commit hooks. These hooks help to identify simple issues before committing code for re ... gross violations. Remember that PEP 8 is only a guide, so respect the style of the surrounding code as a primary goal. An exception to PEP 8 is our rules on line lengths. We allow up to 88 characters in code, as this is the line length used by black . ... tests, use assertRaisesMessage() and assertWarnsMessage() instead of assertRaises() and assertWarns() so you can check the exception or warning message. Use assertRaisesRegex() and assertWarnsRegex() only if you need regular expression matching. Use as ... rts in these groups: future, standard library, third-party libraries, other Django components, local Django component, try/excepts. Sort lines in each group alphabetically by the full module name. Place all import module statements before from module i ...
https://man.mtool.work/django/6.1/internals/contributing/writing-code/coding-sty...
Migrating email to mailers 10663
Migrating email to mailers Django 6.1 introduced the MAILERS setting, replacing EMAIL_BACKEND and several other EMAIL_* settings. It also introduced mail.mailers for obtaining configured email backend instances, replacing mail.get_connectio ... il has been configured but avoid raising an error if it hasn't (e.g., in a reusable library), wrap the send call in try: / except mail.MailerDoesNotExist: pass . To ignore all exceptions (e.g., to avoid cascading failures in an error handler that sends ... mail), wrap the send call in try: / except Exception: pass . To ignore only SMTP-related errors, wrap the send call in try / except OSError: pass . Note that this ig ... fail_silently specifically to ignore those errors, consider instead intercepting SMTPRecipientsRefused and/or SMTPResponseException s with particular smtp_code values as a more precise filter.) To create an email configuration that ignores certain bac ...
https://man.mtool.work/django/6.1/howto/mailers-migration.html
Django の例外 10663
Django の例外 Django は普通の Python の例外の他に、いくつか独自の例外も起こします。 Django Core 例外 Django core 例外クラスは django.core.exceptions で定義されています。 AppRegistryNotReady exception AppRegistryNotReady [ソース] この例外は、 ... を初期化する アプリケーション読み込みプロセス が完了する前にモデルを使用しようとしたときに発生します。 ObjectDoesNotExist exception ObjectDoesNotExist [ソース] Model.DoesNotExist 例外の基底クラスです。 ObjectDoesNotExist のための try/except は、すべて ... のモデルの DoesNotExist 例外をキャッチします。 get() を参照してください。 ObjectNotUpdated New in Django 6.0. exception ObjectNotUpdated [ソース] The base class for Model.NotUpdated exceptions. A try/except for ObjectNotUpdated will catch ... NotUpdated exceptions for all models. save() を参照してください。 EmptyResultSet exception EmptyResultSet [ソース] EmptyResultSet は、クエリ ...
https://man.mtool.work/django/6.1/ref/exceptions.html
QuerySet API リファレンス 9459
QuerySet API リファレンス このドキュメントでは、 QuerySet API の詳細を説明しています。 モデル と データベースクエリ ガイドにある説明を前提としていますので、このドキュメントを読む前にこの 2 つを読んでおくことをおすすめします。 このリファレン ... qs1 . intersection ( qs2 , qs3 ) 制限については union() を参照してください。 difference() difference ( * other_qs ) SQL の EXCEPT 演算子を使用して、 QuerySet には存在するが、他の QuerySet には存在しない要素のみを保持します。例: >>> qs1 . difference ( q ... ncluding an argument from an aggregation (e.g. using the result of annotate() ) doesn't make sense: doing so will raise an exception. The aggregated values will always be fetched into the resulting queryset. 注釈 The defer() method (and its cousin, onl ... その結果、連続して only() を呼び出すと、最後に指定したフィールドだけが考慮されることになります: # This will defer all fields except the headline. Entry . objects . only ( "body" , "rating" ) . only ( "headline" ) defer() は段階的に(遅延読み込みリストにフ ...
https://man.mtool.work/django/6.1/ref/models/querysets.html
独自のテンプレートタグとフィルタを作る 9068
独自のテンプレートタグとフィルタを作る Django のテンプレート言語は、アプリケーションのプレゼンテーションロジックのニーズに対応するように設計された、多種多様な 埋め込みタグやフィルタ を搭載しています。それでもなお、テンプレート構成要素のコア ... 登録します: @register . filter ( expects_localtime = True ) def businesshours ( value ): try : return 9 <= value . hour < 17 except AttributeError : return "" このフラグがセットされていると、フィルタの最初の引数がタイムゾーンを意識した datetime である場合 ... token ): try : # split_contents() knows not to split quoted strings. tag_name , format_string = token . split_contents () except ValueError : raise template . TemplateSyntaxError ( " %r tag requires a single argument" % token . contents . split ()[ 0 ... 数は構文エラーに対して django.template.TemplateSyntaxError を親切なメッセージとともに発生させます。 The TemplateSyntaxError exceptions use the tag_name variable. Don't hardcode the tag's name in your error messages, because that couples the tag's name t ...
https://man.mtool.work/django/6.1/howto/custom-template-tags.html
Django 1.7 リリースノート 8662
Django 1.7 リリースノート September 2, 2014 Django 1.7 へようこそ! このリリースノートでは、 バージョン 1.7 の新機能 と、Django 1.6 以前からアップグレードする際に注意すべき、 後方互換性のない変更 について説明します。 非推奨サイクルが終了した ... iew). Using the former pattern was straightforward since the form can guess from the context (i.e. which method raised the exception) where the errors belong and automatically process them. This remains the canonical way of adding errors when possible. ... is True . This allows template origins to be inspected and logged outside of the django.template infrastructure. TypeError exceptions are no longer silenced when raised during the rendering of a template. The following functions now accept a dirs param ... the beginning of your script with: >>> import django >>> django . setup () Otherwise, you will hit an AppRegistryNotReady exception. WSGI scripts Until Django 1.3, the recommended way to create a WSGI application was: import django.core.handlers.wsgi ...
https://man.mtool.work/django/6.1/releases/1.7.html
Django オブジェクトのシリアライズ 8662
Django オブジェクトのシリアライズ Django のシリアライズフレームワークは、Django のモデルを他のフォーマットに「翻訳」する仕組みを提供します。通常、このような他のフォーマットはテキストベースや Django データをネットワーク越しに送信するために使 ... _string , str ): stream_or_string = stream_or_string . splitlines () try : objects = csv . DictReader ( stream_or_string ) except Exception as exc : raise DeserializationError () from exc super () . __init__ ( objects , ** options ) def _handle_object ... ame : obj [ field . name ] for field in model_fields if field . name in obj } yield from super () . _handle_object ( obj ) except ( GeneratorExit , DeserializationError ): raise except Exception as exc : raise DeserializationError ( f "Error deserializ ...
https://man.mtool.work/django/6.1/topics/serialization.html
Porting your apps from Django 0.96 to 1.0 8271
Porting your apps from Django 0.96 to 1.0 Django 1.0 breaks compatibility with 0.96 in some areas. This guide will help you port 0.96 projects and apps to 1.0. The first part of this document includes the common changes needed to run with 1 ... fields (for example: timestamps) that were auto-populated by a save() now need explicit values in any fixture. 設定 Better exceptions The old EnvironmentError has split into an ImportError when Django fails to find the settings module and a RuntimeErro ... . If you always want a slash on such URLs, rewrite the pattern as: r "/some_prefix/(.*/)$" Smaller model changes Different exception from get() Managers now return a MultipleObjectsReturned exception instead of AssertionError : Old (0.96): try : Model ... . objects . get ( ... ) except AssertionError : handle_the_error () New (1.0): try : Model . objects . get ( ... ) except Model . MultipleObjectsReturned ...
https://man.mtool.work/django/6.1/releases/1.0-porting-guide.html
PREV 1 2 3 4 5 NEXT