... p trailing and leading whitespace from the password fields ( #26334 ). The change requires users who set their password to something with such whitespace after a site updated to Django 1.9 to reset their password. It provides backwards-compatibility for e ... ement path() ( #26297 ). Fixed a crash when using a reverse lookup with a subquery when a ForeignKey has a to_field set to something other than the primary key ( #26373 ). Fixed a regression in CommonMiddleware that caused spurious warnings in logs on req ... ... を行うことができます。たとえば: from django.conf import settings def my_view ( request ): if settings . SITE_ID == 3 : # Do something. pass else : # Do something else. pass It's fragile to hardcode the site IDs like that, in case they change. The cleaner w ... ent_site def my_view ( request ): current_site = get_current_site ( request ) if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass これには、サイトフレームワークがインストールされているかどうかを確認するという利点も ... y_function_without_request (): current_site = Site . objects . get_current () if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass 表示用の現在のドメインを取得する LJWorld.com と Lawrence.com はどちらも、ニュースが発 ... ... document . addEventListener ( 'formset:added' , ( event ) => { if ( event . detail . formsetName == 'author_set' ) { // Do something } }); document . addEventListener ( 'formset:removed' , ( event ) => { // Row removed }); 注意点が2つあります: もし admin/ ... クし、次のように古いリスナーのシグネチャにフォールバックできます: function handleFormsetAdded ( row , formsetName ) { // Do something } $ ( document ). on ( 'formset:added' , ( event , $row , formsetName ) => { if ( event . detail && event . detail . forms ... ... e some documentation Django's documentation is great but it can always be improved. Did you find a typo? Do you think that something should be clarified? Go ahead and suggest a documentation patch! See also the guide on ドキュメントを書く . 注釈 reports p ... ango での作業をより便利でやりがいのあるものにするためのアドバイスをいくつか紹介します。 Pick a subject area This should be something that you care about, that you are familiar with or that you want to learn about. You don't already have to be an expert on ... ... an't possibly document everything that's new in 1.0, but the documentation will be your definitive guide. Anywhere you see something like: New in Django 1.0: This feature is new in Django 1.0 You'll know that you're looking at something new or changed. Th ... ... カスタムエラーメッセージです: >>> formset = ArticleFormSet ( ... {}, error_messages = { "missing_management_form" : "Sorry, something went wrong." } ... ) >>> formset . is_valid () False >>> formset . non_form_errors () ['Sorry, something went wrong.'] フォ ... request . method == "POST" : formset = ArticleFormSet ( request . POST , request . FILES ) if formset . is_valid (): # do something with the formset.cleaned_data pass else : formset = ArticleFormSet () return render ( request , "manage_articles.html" , { ... equest . POST , request . FILES , prefix = "books" ) if article_formset . is_valid () and book_formset . is_valid (): # do something with the cleaned_data on the formsets. pass else : article_formset = ArticleFormSet ( prefix = "articles" ) book_formset = ... ... f import csrf_exempt , csrf_protect @csrf_exempt def my_view ( request ): @csrf_protect def protected_path ( request ): do_something () if some_condition (): return protected_path ( request ) else : do_something_else () HTML フォームなしで AJAX を使用する ... ... スがセットされます。 両者は、 is_authenticated を用いて次のように識別できます。 if request . user . is_authenticated : # Do something for authenticated users. ... else : # Do something for anonymous users. ... 非同期ビューでは次のようになります。 user = aw ... ait request . auser () if user . is_authenticated : # Do something for authenticated users. ... else : # Do something for anonymous users. ... ユーザーをログインさせる方法 現在のセッションに ... add_vote %} 以下は、テンプレートで権限をチェックする、より完全な例です: {% if perms.foo %} < p > You have permission to do something in the foo app. </ p > {% if perms.foo.add_vote %} < p > You can vote! </ p > {% endif %} {% if perms.foo.add_driving %} < ... ... w and DetailView ); similarly, it's unlikely that you'll need to override it, although if you want your response to return something not rendered via a Django template then you'll want to do it. For an example of this, see the JSONResponseMixin example . ... is <app_label>/<model_name>_detail.html . The _detail part can be changed by setting template_name_suffix on a subclass to something else. (For instance, the generic edit views use _form for create and update views, and _confirm_delete for delete views.) ... lly we bring this together in a new AuthorView view. We already know that calling as_view() on a class-based view gives us something that behaves exactly like a function based view, so we can do that at the point we choose between the two subviews. You ca ... ... す: # don't save to the database >>> instances = formset . save ( commit = False ) >>> for instance in instances : ... # do something with instance ... instance . save () ... これにより、データベースに保存する前にインスタンスにデータを付加できます。フォーム ... == "POST" : formset = AuthorFormSet ( request . POST , request . FILES ) if formset . is_valid (): formset . save () # do something. else : formset = AuthorFormSet () return render ( request , "manage_authors.html" , { "formset" : formset }) 見てのとおり ... uthorFormSet ( request . POST , request . FILES , queryset = queryset , ) if formset . is_valid (): formset . save () # Do something. else : formset = AuthorFormSet ( queryset = queryset ) return render ( request , "manage_authors.html" , { "formset" : fo ... 2026年10月08日