Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Foreign key error message in WTForms validation

See original GitHub issue

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:open
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

AnastassiyaPcommented, Aug 24, 2018

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.

coleifercommented, Aug 23, 2018

Is this the same as the issue you just opened, #46 ? Are they related?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found