... 性があります。これは 2 つの方法で解決できます: >>> When ( then__exact = 0 , then = 1 ) >>> When ( Q ( then = 0 ), then = 1 ) Case class Case ( * cases , ** extra ) [ソース] Case() 式は Python の if ... elif ... else 文のようなものです。指定された When( ... オブジェクトの result 式が返されます。 例: >>> >>> from datetime import date , timedelta >>> from django.db.models import Case , Value , When >>> Client . objects . create ( ... name = "Jane Doe" , ... account_type = Client . REGULAR , ... registere ... ), ... ) >>> # Get the discount for each Client based on the account type >>> Client . objects . annotate ( ... discount = Case ( ... When ( account_type = Client . GOLD , then = Value ( "5%" )), ... When ( account_type = Client . PLATINUM , then = V ... ... into that account. バグ修正 Fixed check for template engine alias uniqueness ( #24685 ). Fixed crash when reusing the same Case instance in a query ( #24752 ). Corrected join promotion for Case expressions. For example, annotating a query with a Case ... expression could unexpectedly filter out results ( #24766 ). Fixed negated Q objects in expressions. Cases like Case(When(~Q(friends__age__lte=30))) tried to generate a subquery which resulted in a crash ( #24705 ). Fixed incorr ... ... llows the use case of binding to a specific port following the bind to port zero change in Django 1.11. バグ修正 Added detection for GDAL 2.1 ... ed the ImageField file extension validation added in Django 1.11 from the model field to the form field to reallow the use case of storing images without an extension ( #28242 ). ... ... Fixed recording of applied status for squashed (replacement) migrations ( #24628 ). Fixed queryset annotations when using Case expressions with exclude() ( #24833 ). Corrected join promotion for multiple Case expressions. Annotating a query with mul ... tiple Case expressions could unexpectedly filter out results ( #24924 ). Fixed usage of transforms in subqueries ( #24744 ). Fixed Si ... mpleTestCase.assertRaisesMessage() on Python 2.7.10 ( #24903 ). Provided better backwards compatibility for the verbosity argument in o ... ... uthor email. # AUTHOR LINK --One of the following three is optional. The framework # looks for them in this order. In each case, the URL should include # the scheme (such as "https://") and domain name. def author_link ( self , obj ): """ Takes the o ... author URL. # CATEGORIES -- One of the following three is optional. The framework # looks for them in this order. In each case, the method/attribute # should return an iterable object that returns strings. def categories ( self , obj ): """ Takes th ... email. # ITEM AUTHOR LINK -- One of the following three is optional. The # framework looks for them in this order. In each case, the URL should # include the scheme (such as "https://") and domain name. # # If you specify this, you must specify item_ ... ... you need to do additional work on your branch, commit as often as necessary: git commit -m 'Added two more tests for edge cases.' Publishing work You can publish your work on GitHub by running: git push origin ticket_xxxxx When you go to your GitHub ... t fetch upstream git rebase upstream/main The work is automatically rebased using the branch you forked on, in the example case using upstream/main . The rebase command removes all your local commits temporarily, applies the upstream commits, and the ... After review It is unusual to get any non-trivial amount of code into core without changes requested by reviewers. In this case, it is often a good idea to add the changes as one incremental commit to your work. This allows the reviewer to easily che ... ... technically backwards-incompatible, but the security risks have been judged to outweigh the compatibility concerns in this case. Additionally, Django will now accept the CSRF token in the custom HTTP header X-CSRFTOKEN, as well as in the form submiss ... pletely worked as advertised. When using database backends that don't support transactions, or when using a TransactionTestCase, data that has been inserted using custom SQL will not be visible during the testing process. Unfortunately, there was no ... o exist during test conditions, you should either insert it using test fixtures , or using the setUp() method of your test case. ModelAdmin.lookup_allowed signature changed Django 1.2.4 introduced a method lookup_allowed on ModelAdmin , to cope with ... ... of Unicode characters, that compared equal to an existing user email when lower-cased for comparison, an attacker could be sent a password reset token for the matched account. In order to avoid this vulnerab ... ility, password reset requests now compare the submitted email using the stricter, recommended algorithm for case-insensitive comparison of two identifiers from Unicode Technical Report 36, section 2.11.2(B)(2) . Upon a match, the email ... ... icode characters, that compared equal to an existing user email when lower-cased for comparison, an attacker could be sent a password reset token for the matched account. In order to avoid this vulnerab ... ility, password reset requests now compare the submitted email using the stricter, recommended algorithm for case-insensitive comparison of two identifiers from Unicode Technical Report 36, section 2.11.2(B)(2) . Upon a match, the email ... ... that was created with 64-bit constraints, you will need to manually drop the old constraint prior to invoking reset . Test cases are now run in a transaction Django 1.1 runs tests inside a transaction, allowing better test performance (see test perfo ... transactional behavior, if they rely on invalid assumptions about the test environment, or if they require a specific test case ordering. For these cases, TransactionTestCase can be used instead. This is a just a quick fix to get around test case err ... ors revealed by the new rollback approach; in the long-term tests should be rewritten to correct the test case. Removed SetRemoteAddrFromForwardedFor middleware For convenience, Django 1.0 included an optional middleware class -- dja ... 2026年10月08日