Validation Error doesn`t show

I have in my template with a form in which data is collected in 2 Django forms but sent to the view in the same post like this:

<form action="" method="post">
        {% csrf_token %}
        <div class="form1">
                           <div>
                <label for="field1">field1</label>
                {{ form1.field1 }}
            </div>
            <div>
                <label for="field2">field2</label>
                {{ form1.field2 }}
            </div>
            <div>
                <label for="field3">field3</label>
                {{ form1.field3 }}
            </div>
        </div>
        {{ form2set.management_form }}

        <div id='form2set-form-list'>
            {% for form in form2set %}
            <div class='form2set-form'>
                {{ form.as_p }} 
            </div>
            {% endfor %}
        </div>
            <input type="submit">
        </div>
    </form>

The data is collected in the view and validated. To validate, I have validations declared in both forms. In case the validations fail because the data is incorrect, they return a raise (depending on which one or ones have failed). This raise is what should be shown on the screen to the user as an error.

If the failed validation is in the second form, it displays the error correctly and without problems. Now, in the case that the failure is in the first form, the page simply reloads and does not show the error. The data already entered in the form is not lost and can be corrected, but the error is not displayed.

My view is something like this:

def create(request):
    form1 = Form1(request.POST or None)
    form2 = formset_factory(Form2, extra=0)
    form2Set = form2(request.POST or None, prefix='participant')
    
    context = {
        'form1': form1,
        'form2Set': form2Set,
    }

    if request.method == 'POST':
        if form1.is_valid() and form2Set.is_valid():
            # Logic
        else:
            context['form1'] = form1
            context['form2Set'] = form2Set

    return render(request, 'template', context)

Are you saying that if there is an error in form1, then errors in form1 don’t get displayed? Or are you saying that if there is an error in form1, then errors in form 2 don’t get displayed?

If it’s the latter case that concerns you, then the issue is this:

The Python and operator short-circuits the expression evaluations. If form1.is_valid() is False, then Python is not going to evaluate form2Set.is_valid(). If you want both forms validated, you can call full_clean on both forms before the if. (The errors are stored within the object, Django won’t go through the clean process if the error dict is already populated.)

Im saying that if there are a error in form1 don’t get display but thx for that info

i just see thx to a user of the discord that if i write this in the template it show the error, the problema was that i was only showing the field in my template

{{ sorteo_form.as_p }}

Ok, so your original post did not show the template you were using - you had edited it down to a simplified version, hiding the actual source of the problem.

Please don’t do that in the future. When requesting assistance here, copy/paste the real code showing the issue.

Yeah sry that was my bad