Foreign key error message in WTForms validation
See original GitHub issueIssue Description
When I try to post a new object with foreign key field that doesn’t match to any object in the database, I get the same message, as when I don’t pass this field at all:
{
"region": [
"This field is required."
]
}
It looks like a bug.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
WTForms getting the errors - Stack Overflow
Since I'm building a rest application which uses no form views, I'm forced to check through all form fields in order to find...
Read more >Flask Form Validation with Flask-WTF - Stack Abuse
WTForms is a popular Python library that validates form data. This tutorial shows you how to use WTForms with Flask to create and...
Read more >Form Validation with WTForms — Flask Documentation (1.1.x)
When you have to work with form data submitted by a browser view, code quickly becomes very hard to read. There are libraries...
Read more >Validators — WTForms Documentation (2.3.x)
message – Error message to raise in case of a validation error. Can be interpolated using %(min)d and %(max)d if desired. Useful defaults...
Read more >WTForms Documentation
Validates the form by calling validate on each field, ... exclude_fk – An optional boolean to force foreign keys exclusion.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
They are related, but I am not sure that this is the same case.
In the case of required param with wrong foreign key validation fails as expected but the error message is incorrect. In the case of an optional param, validation succeeds.
But maybe Exception on DoesNotExist in the get_model() will fix both cases, I don’t know.
Is this the same as the issue you just opened, #46 ? Are they related?