-
Notifications
You must be signed in to change notification settings - Fork 66
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
Validation on models with deferred related model does no fully work #114
Comments
Any updates on this? I just ran into the same issue when I wanted to ensure that a Wagtail form builder form includes at least an email field and a first name field (for sending confirmation mails). |
I've also identified this same issue, with a Wagtail application which has a Page that includes some Orderables which have a ParentalKey relation back to the Page model. The Page model's My use case is not actually validation, but calculating some hidden fields in both the Page and the Orderable based on data in the other (ultimately to make the database queries much simpler). In my case, I can make those field calculations in the model's |
I have this issue too. I was tryin to check the number of related pages ( |
Attempting to validate a Form Page in Wagtail that has FormFields associated with it via a ParentalKey doesn't allow us to validate that certain formfields make sense. In the
clean
function of the Page, any call to my related object queryset doesn't return any of the about to be created form fields, only ones that already exist.The requirement: We have some email related fields that rely on certain form fields potentially existing, so if one of those fields is set, we validate that the formfield exists.
The issue: Until the page is actually saved, those form fields don't exist, so validating against form fields that are about to be saved in page.clean doesn't work. We first have to create the form fields, then add to that field, then save again.
Steps to reproduce:
Using a form page based on the below code, go to create a new page.
On that new page set a form field with the name
email
and populatereply_to_from_field
with the same. Save draft. Despite the form field existingreply_to_from_field
will raise a validation error.If you unset
reply_to_from_field
, then save draft, and then fillreply_to_from_field
, and save again, it will now work.Expected result
Some way to get at the deferred objects when validating the Page model, so we can check if the models about to be created will actually fulfil the requirements of the Page.
Our code
The text was updated successfully, but these errors were encountered: