0

Is it possible to add form errors (not a field specific errors) to a form that is already validated (form.is_valid() is already called and the result is True)?

I have additional validation logic (with database requests) which I prefer to execute after standard form validation is passed, but it will be better to associate new errors with form

Or maybe I have to call this additional validation within clear() form function?

2 Answers 2

2

Try to check it in the clean method of the form after all, but check existing errors before. Like that..

clean(self):
    ...
    ...
    if not self._errors:
        # your extra check
Sign up to request clarification or add additional context in comments.

Comments

0

If this is validation based on database requests, then it shound as model validation.

1 Comment

I don't have a model involved in these database requests, it's a raw sql that call one database function. And the result can indicate incorrect data in form, that's why I want to associate errors with form

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.