# Rerender form without validation

**URL:** <https://forum.djangoproject.com/t/rerender-form-without-validation/31289>\
**Category:** Forms & APIs\
**Created:** [May 18, 2024, 8:31pm UTC](https://forum.djangoproject.com/t/rerender-form-without-validation/31289 "2024-05-18T20:31:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandremjacques](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alexandremjacques/32/893_2.png) [@alexandremjacques](https://forum.djangoproject.com/u/alexandremjacques)\
**Post date:** [May 18, 2024, 8:31pm UTC](https://forum.djangoproject.com/t/rerender-form-without-validation/31289/1 "2024-05-18T20:31:01Z")

</div>

Hi, I’m using Unpoly which has a feature (`up-validate`) that submits a forms with a request header so that I could rerender my form with new information (like pre-populate some other fields).

I can, on my view, check for that header and recreate the form with the new information.

My problem is that, even if I don’t call `is_valid()`, on sending the form back, the form has errors.

Is there a way to avoid that validation (my guess it’s the model validation kicking in since this is the form is a `ModelForm`).

Update: even with a non-`ModelForm`, it still has errors before `is_valid()`.

```auto
    def post(self, request):
        if request.is_up_validate: <---- Middleware that checks Unpoly header
            some_id = request.POST.get('some_id', None)

            form = SomethingForm(
                request.POST,
                user_id=request.user.id,
                some_id=some_id
            )

            logger.debug (form.errors) <---- Form has errors

            return render(request, 'template_name.html', {'form': form})

```

TIA

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 18, 2024, 11:01pm UTC](https://forum.djangoproject.com/t/rerender-form-without-validation/31289/2 "2024-05-18T23:01:50Z")

</div>

> [@alexandremjacques](#):
>
> Update: even with a non-`ModelForm`, it still has errors before `is_valid()`.

This isn’t quite a fully-accurate statement.

The errors in a form are stored in an internal attribute named `_errors`. This dict is populated by the `full_clean` method. There are a number of different ways that `full_clean` can end up being called, and `is_valid` is only one of them. Referencing the `errors` attribute of the form will also cause `full_clean` to be called if it hasn’t already been done.

In other words, this statement:

> [@alexandremjacques](#):
>
> `logger.debug (form.errors) <---- Form has errors`

would actually cause `full_clean` to be called.

If I were to make a guess, you could probably set `form._errors = ErrorDict()` after binding the form. Or, you may be able to override the `full_clean` method to reset the `_errors` attribute after the other processing has been done.

---

<div class="post-metadata">

**Author:** ![alexandremjacques](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/alexandremjacques/32/893_2.png) [@alexandremjacques](https://forum.djangoproject.com/u/alexandremjacques)\
**Post date:** [May 19, 2024, 3:22am UTC](https://forum.djangoproject.com/t/rerender-form-without-validation/31289/3 "2024-05-19T03:22:40Z")

</div>

Thanks for the detailed explanation. The proposed solution with`ErrorDict()` worked just fine. 🙂
