-
Notifications
You must be signed in to change notification settings - Fork 80
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
wagtail v4 new page issue #200
Comments
I'm having the same problem. |
The Problem here is, that wagtail reworked the BaseChooser Widget. Wagtailstreamforms created a FormChooser which inherits wagtails BaseChooser and overwrites the inner widget, which does not work anymore. I was not able to figure out how get the FormChooser to run again under the new circumstances but figured we could just use a ChoiceBlock instead. So here are the good news, at least for a hotfix inside your own Project.
Keep in mind that a ChoiceBlock returns a string, which makes it neccessary to overwrite the serializer as well, since it is expecting a model instance and not a string representation of a model.
I bet that you could simply write a simple template tag that does exactly that if you are using wagtail the standard way to render your content. Hope this helps at least for a quickfix and possibly with fixing the problem long term. |
Thanks, this helps a lot, I've already forked this project locally and got it working w/ v3, but wanting to move to v4. Haven't dived too deep, so excuse my ignorance, but that snippet is just for API, or will it also work for non-headless? |
Hey @TonisPiip no worries, It will work for your case as well, but as i already mentioned you probably need a custom template tag to deliver the form instance to your template. I would try overwriting the formblock template (docs) I imagine the formblock template would look similar to this:
and the provided logic inside your custom_tags.py should look similar to:
|
Thank you very much for your suggestions. ADD THIS to your models.py
AND USE it like that in your StreamField
|
ah sweet the render method is a much better solution, thank you for the input :) also glad i could help. |
As any time a form is added a new migration is wanted to be made.... |
This is my hacky solution for not having db changes make django want to make a new migration, as well as having it possible for django to start w/o having a working db connection all the time. |
This might be overkill, but when ran into the same problem on a Wagtail 4.1.1 upgrade I pulled in https://github.com/wagtail/wagtail-generic-chooser and used it to create a streamforms chooser...seems to work In
Then in your
|
@marts Thank you very much for the code. I will be using it in my project in a while. Have you testing it with wagtail v4.2? I would hope it would work |
@TonisPiip I've only tried it with Wagtail 4.1.1 - I try to stick with the Long Term Support releases generally, but I would have thought it will work fine on 4.2. |
Based on #200 (comment), wagtail_generic_chooser is introduced to solve #200. Also, wagtail 4.2 support is added and Django 4.1
* Update to version 3.22 Based on #200 (comment), wagtail_generic_chooser is introduced to solve #200. Also, wagtail 4.2 support is added and Django 4.1 * format files * seperate -- from command arg * set max version for wagtail-generic-chooser
With the new release, 3.22, just should be fixed. Let me know if that version works for you @TonisPiip. Thank you very much @marts for your solution to this issue. |
@VdeJong Thanks for the release, just tested with 4.2 and it worked. I can't confirm if the choices issue exists or not as I suppressed new migrations on StreamField changes. There's still some |
When trying to crate a new page in the example django app in the project the following error happens.
Seems to relate to the
FormChooserBlock
as when I comment outform = FormChooserBlock()
(line #45 in blocks.py) the page renders.Can't seem to see what the issue could be. But this might be the only blocker for supporting version 4?
To reproduce, edit the setup.py to require
wagtail==4.0.*
docker-compose up
then try to add a child page to the default page.The text was updated successfully, but these errors were encountered: