New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a translated page Error: string
must be either a StringValue
or a str
. Got NoneType
#690
Comments
If I get the time I may try to set up a dev environment, but adding a CONTRIBUTING.md would really help! |
Thanks @PeteCoward |
@zerolab I suspect I was wrong here, from what I can understand so far StringSegmentValue is used both for:
The behaviour of suppressing empty sections of RichText makes sense now to me, but it seems to make sense to me to make sure that empty values are available for translation if they are top level fields on models or blocks. I wanted to check my understanding with you not being familiar with the codebase before diving into some kind of solution which might involve a refactor to |
@PeteCoward I need to make that dive myself as it has been a while since I looked and the two segments. It is worth noting they have been added prior to Wagtail requiring |
I figure you might still want to support use_json_field=False for a while though? |
Most definitely. Wagtail 4.1, which is an LTS still supports |
If you have a page type with a StreamField, which uses a StructBlock, and you add a new
TextBlock(required=False)
field to that struct block, and run all migrations, the resultant JSON in the db will contain aNone
value.StreamFieldSegmentExtractor
fails to handle thatNone
value, and an exception is thrown.I got around this by a custom stream field data migration forceably setting that field on all instances of the StructBlock, but it's a bit painful and is lying in wait for my team and any others who might do this in future.
Some simple changes to
StringSegmentValue
could fix this I think, but I ended up going with the data migration. I did fork initially, but pip installing from my fork failed due to the javascript compilation not being run. Then I looked for another solution and went with data migrations.The text was updated successfully, but these errors were encountered: