#33871 closed Bug (duplicate)
JSONField with default is not detected as changed when invalidated in inlines.
Reported by: | Raphael | Owned by: | JunKi Yoon |
---|---|---|---|
Component: | Forms | Version: | 4.0 |
Severity: | Normal | Keywords: | JSONField TabularInline |
Cc: | Carlton Gibson | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Apparently the JSONField field modification in a TabularInline is ignored after a validation error.
To reproduce I attached the generated project based of the basic Django tutorial with changes to use a JSONField and TabularInline
user: admin
password: admin
Sequence:
- Edit the Question
- Change both Text field to "test"
- Change both JsonField to 'test' (Any Valid Json)
- Save
- Edit again
- Change both two JsonField to 'test 123' (Any Valid Json)
- Delete text from Text field of the second item
- Save
- Error message will appear
- Set the Choice Text field to 'test 123' of the second item
- Save
- Edit again, only the second JsonField was changed to 'test 123' (Any Valid Json)
Attachments (1)
Change History (17)
by , 2 years ago
Attachment: | djangoInlineBug.zip added |
---|
comment:1 by , 2 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
comment:3 by , 2 years ago
Description: | modified (diff) |
---|
comment:4 by , 2 years ago
Description: | modified (diff) |
---|
follow-ups: 6 11 comment:5 by , 2 years ago
Cc: | added |
---|---|
Component: | contrib.admin → Forms |
Severity: | Release blocker → Normal |
Summary: | Bug that occurs when using JSONField and TabularInline → JSONField with default is not detected as changed when invalidated in inlines. |
Triage Stage: | Unreviewed → Accepted |
follow-up: 7 comment:6 by , 2 years ago
Replying to Mariusz Felisiak:
Is this still a bug that needs to be fixed?
follow-up: 8 comment:7 by , 2 years ago
comment:8 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Replying to Mariusz Felisiak:
Ok, I will try. Thank you for reply :)
follow-up: 10 comment:9 by , 2 years ago
Replying to Raphael, Mariusz Felisiak:
Hi, Raphael. I want to patch this issue.
- So, Could you plz give me the URL for the basic Django tutorial ?
- And, I downloaded your attachments. I have a question about sequence you wrote. Did you run it from the admin page ? or Django shell ?
- Did you mean, right?
two TextField -> Question.question_text, Choice.choice_text, one JsonField -> Choice.test
How can I reproduce ?
comment:10 by , 2 years ago
Hello,
- So, Could you plz give me the URL for the basic Django tutorial ?
--- https://docs.djangoproject.com/en/4.1/intro/tutorial01/
- And, I downloaded your attachments. I have a question about sequence you wrote. Did you run it from the admin page ? or Django shell ?
-- Admin page
- Did you mean, right?
-- I didn't really understand the question, but in the sample I attached is another field. I don't think this is relevant to the problem. I think it's easier for you to use the sample I sent.
How can I reproduce ?
Run the code and follow the Sequence. You will see that the data will not be store correctly.
Thank you.
Replying to JunKi Yoon:
Replying to Raphael, Mariusz Felisiak:
Hi, Raphael. I want to patch this issue.
- So, Could you plz give me the URL for the basic Django tutorial ?
- And, I downloaded your attachments. I have a question about sequence you wrote. Did you run it from the admin page ? or Django shell ?
- Did you mean, right?
two TextField -> Question.question_text, Choice.choice_text, one JsonField -> Choice.testHow can I reproduce ?
comment:11 by , 2 years ago
Replying to Mariusz Felisiak:
Hi Mariusz Felisiak :)
After debugging, I confirmed that the initial-choice_set-0-test and choice_set-0-test are same.
So, I guess one thing. initial-choice_set-0-test is not the value that the Choice object currently has.
initial-choice_set-0-test value after showing error message by sequence 8 is stored as the input value in sequence 6.
Could you plz give me some advice regarding where to set the initial-XXX-XXX and code?
Thank you.
cc) Raphael
Thanks for the detailed report.
initial
value is set to a new value when invalidated, that's why changes are not detected:
choice_set-0-test="test 123" initial-choice_set-0-test="test 123"
follow-up: 14 comment:13 by , 2 years ago
Patch needs improvement: | set |
---|
Current patch is mixing solution between forms and admin components. Slightly clearer tests showing the problem would probably clarify.
comment:14 by , 2 years ago
Replying to Carlton Gibson:
Current patch is mixing solution between forms and admin components. Slightly clearer tests showing the problem would probably clarify.
I Improved patch and tests. :)
comment:15 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Triage Stage: | Accepted → Unreviewed |
Duplicate of #34119.
comment:16 by , 2 years ago
Confirmed the patch for #34119 fixes the issue with sample models provided and steps described above.
Thanks for the detailed report.
initial
value is set to a new value when invalidated, that's why changes are not detected: