Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9608678

Browse files
JasonLovesDoggosarahboyce
authored andcommitted
Fixed #36262 -- Made GeneratedField.db_persist a required key-word argument.
1 parent334677a commit9608678

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

‎AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ answer newbie questions, and generally made Django that much better:
479479
Jarek Głowacki <jarekwg@gmail.com>
480480
Jarek Zgoda <jarek.zgoda@gmail.com>
481481
Jarosław Wygoda <jaroslaw@wygoda.me>
482+
Jason Cameron <https://jasoncameron.dev>
482483
Jason Davies (Esaj) <https://www.jasondavies.com/>
483484
Jason Huggins <http://www.jrandolph.com/blog/>
484485
Jason McBrayer <http://www.carcosa.net/jason/>

‎django/db/models/fields/generated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GeneratedField(Field):
1515
_query=None
1616
output_field=None
1717

18-
def__init__(self,*,expression,output_field,db_persist=None,**kwargs):
18+
def__init__(self,*,expression,output_field,db_persist,**kwargs):
1919
ifkwargs.setdefault("editable",False):
2020
raiseValueError("GeneratedField cannot be editable.")
2121
ifnotkwargs.setdefault("blank",True):

‎docs/ref/models/fields.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ when :attr:`~django.forms.Field.localize` is ``False`` or
12781278
``GeneratedField``
12791279
------------------
12801280

1281-
.. class:: GeneratedField(expression, output_field, db_persist=None, **kwargs)
1281+
.. class:: GeneratedField(*,expression, output_field, db_persist, **kwargs)
12821282

12831283
A field that is always computed based on other fields in the model. This field
12841284
is managed and updated by the database itself. Uses the ``GENERATED ALWAYS``

‎tests/model_fields/test_generatedfield.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def test_database_default_unsupported(self):
9494
)
9595

9696
deftest_db_persist_required(self):
97-
msg="GeneratedField.db_persist must be True or False."
98-
withself.assertRaisesMessage(ValueError,msg):
97+
withself.assertRaises(TypeError):
9998
GeneratedField(
10099
expression=Lower("name"),output_field=CharField(max_length=255)
101100
)
101+
msg="GeneratedField.db_persist must be True or False."
102102
withself.assertRaisesMessage(ValueError,msg):
103103
GeneratedField(
104104
expression=Lower("name"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp