... and return values are serialized to JSON, they must be JSON-serializable: >>> process_data . enqueue ( datetime . now ()) Traceback (most recent call last): ... TypeError : Object of type datetime is not JSON serializable Arguments must also be able to r ... t backend: >>> result = double_dictionary . enqueue (( 1 , 2 , 3 )) >>> result . status FAILED >>> result . errors [ 0 ] . traceback Traceback (most recent call last): ... TypeError : unhashable type: 'list' The double_dictionary Task fails because after ... ask has not finished executing, or has failed, ValueError is raised. >>> result . status RUNNING >>> result . return_value Traceback (most recent call last): ... ValueError : Task has not finished yet Errors If the Task doesn't succeed, and instead raises ... ... 、通常は、エラーに関する関連情報をできるだけ多く記録しておくと便利です。例えば、デフォルトでは Django は発生した例外の full traceback や、各 traceback frame のローカル変数、 HttpRequest の 属性 を記録します。 しかし、例えばユーザのパスワードやクレジットカー ... SECRET|PASS|SIGNATURE|HTTP_COOKIE" , flags = re . IGNORECASE ) is_active ( request ) [ソース] get_post_parameters() と get_traceback_frame_variables() のフィルタリングを有効にする場合は True を返します。デフォルトでは DEBUG が False の場合に有効になります ... [ソース] フィルタリングされた POST パラメータの辞書を返します。センシティブな値は cleansed_substitute で置換されます。 get_traceback_frame_variables ( request , tb_frame ) [ソース] 与えられたトレースバックフレームのローカル変数のフィルタリングされた辞書を ... ... 2 . has_next () False >>> page2 . has_previous () True >>> page2 . has_other_pages () True >>> page2 . next_page_number () Traceback (most recent call last): ... EmptyPage : That page contains no results >>> page2 . previous_page_number () 1 >>> page2 . s ... first item on this page 3 >>> page2 . end_index () # The 1-based index of the last item on this page 4 >>> p . page ( 0 ) Traceback (most recent call last): ... EmptyPage : That page number is less than 1 >>> p . page ( 3 ) Traceback (most recent call la ... ... ... re set to None . シグナル Exceptions from the (receiver, exception) tuples returned by Signal.send_robust() now have their traceback attached as a __traceback__ attribute. The environ argument, which contains the WSGI environment structure from the reques ... le: >>> book = Book . objects . create ( name = "Django" ) >>> book . author = Author ( name = "John" ) >>> book . save () Traceback (most recent call last): ... ValueError : save() prohibited to prevent data loss due to unsaved related object 'author'. A ... o" ) >>> book . author >>> Now, an error will be raised to prevent data loss: >>> book . author = Author ( name = "john" ) Traceback (most recent call last): ... ValueError : Cannot assign "<Author: John>": "Author" instance isn't saved in the database. I ... ... f = forms . EmailField () >>> f . clean ( "foo@example.com" ) 'foo@example.com' >>> f . clean ( "invalid email address" ) Traceback (most recent call last): ... ValidationError : ['Enter a valid email address.'] field のコアとなる引数 各 Field クラスのコ ... 発生させます。 >>> from django import forms >>> f = forms . CharField () >>> f . clean ( "foo" ) 'foo' >>> f . clean ( "" ) Traceback (most recent call last): ... ValidationError : ['This field is required.'] >>> f . clean ( None ) Traceback (most recent c ... デフォルトのエラーメッセージです: >>> from django import forms >>> generic = forms . CharField () >>> generic . clean ( "" ) Traceback (most recent call last): ... ValidationError : ['This field is required.'] そしてこれがカスタムエラーメッセージです: >>> n ... ... xecuted the Task. Task errors class TaskError Contains information about the error raised during the execution of a Task . traceback The traceback (as a string) from the raised exception when the Task failed. exception_class The exception class raised whe ... ... ... >>> Article . objects . create ( ... headline = "This is a test" , pub_date = date ( 2005 , 7 , 27 ), reporter = r3 ... ) Traceback (most recent call last): ... ValueError : save() prohibited to prevent data loss due to unsaved related object 'reporter'. ... orter <Reporter: Paul Jones> 間違った型のオブジェクトを追加すると TypeError が発生します: >>> r . article_set . add ( r2 ) Traceback (most recent call last): ... TypeError : 'Article' instance expected, got <Reporter: Paul Jones> >>> r . article_set . all ... ... s you build web apps easily" ) 保存するまでは Publication と関連付けることはできません: >>> a1 . publications . add ( p1 ) Traceback (most recent call last): ... ValueError : "<Article: Django lets you build web apps easily>" needs to have a value for fie ... publications . add ( p3 ) 間違った型のオブジェクトを追加すると TypeError が発生します: >>> a2 . publications . add ( a1 ) Traceback (most recent call last): ... TypeError : 'Publication' instance expected Article に Publication をワンステップで作成・追加 ... 2026年10月08日